def count_mpmcts(filename):
    """
    Given a .pla file with a list of MPMCT gates, tally up the number
    of gates with each different number of controls

    Parameters:
        filename (str): Name of a .pla-formatted file

    Outputs:
        num_total_controls (int): the maximum number of control bits
        mpmct_tally (dict[int, int])): A dictionary with keys as the number of control bits
            and values as the number of occurences of that many controls in the .pla file. 
    """

    mpmct_tally = {}
    num_total_controls = -1

    # Use the output PLA file to determine how many MPMCTs with each
    # different number of possible controls
    with open(filename, "r") as exorcised_file:
        gate_lines = exorcised_file.readlines()[11:-1]

        for line in gate_lines:
            control_string = line.strip().split(" ")[0]
            num_controls = len(control_string) - control_string.count("-")

            if num_total_controls == -1:
                num_total_controls = len(control_string)

            if num_controls not in mpmct_tally:
                mpmct_tally[num_controls] = 1
            else:
                mpmct_tally[num_controls] += 1

    return num_total_controls, mpmct_tally