def counting_interactions(interacting_structures, id_structure_dict):
    """
    Counting the interactions each structure has with each other in order to
    take the most interacting structure as the template for the superimposition.
    """
    count_interactions = {}
    for structure in id_structure_dict.keys():
        count_interactions[structure] = 0
        for interaction in interacting_structures:
            if structure in interaction:
                count_interactions[structure] += 1
    sorted_count_interactions = sorted(count_interactions.items(), key=lambda
        x: x[1], reverse=True)
    return sorted_count_interactions
