from typing import Counter


def get_puzzel_answer(connection_counter, poly_template) -> int:
    """Count each pair and calculate the puzzel result

    What do you get if you take the quantity of the most common element and
    subtract the quantity of the least common element?

    Args:
        connection_counter (Counter): Initial count of each connection
        poly_template (str): initial polymer structur

    Returns:
        int:    puzzel result

    Examples:
        >>> get_puzzel_answer(Counter({'AC': 5, 'BA': 4, 'CB': 1}), "ABC")
        3
    """
    char_counter = Counter()
    for k in connection_counter:
        char_counter[k[0]] += connection_counter[k]
    # The last charakter of the polymer needs to be counted as well
    char_counter[poly_template[-1]] += 1
    return max(char_counter.values()) - min(char_counter.values())