import collections


def count_binary_set_size(nexus_obj):
    """
    Counts the number of sites by their size (i.e. how many sites have two
    members, etc)

    Returns a dictionary of the set size and count

    :param nexus_obj: A `NexusReader` instance
    :type nexus_obj: NexusReader

    :return: A Dictionary

    e.g. {
        0: 0,
        1: 100,
        2: 20,
    }
    """
    tally = collections.Counter()
    for char_id in nexus_obj.data.characters:
        char = nexus_obj.data.characters[char_id]
        tally[len([v for v in char.values() if v == '1'])] += 1
    return tally