def count_pairs(sets):
    """Computes the number of unordered elelemt pairs in disjoint sets."""
    total_size = total_pairs = 0

    for size in sets.sizes():
        total_pairs += total_size * size
        total_size += size

    return total_pairs