Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as a guest on somebody else's stadium, the players put on the guest uniform. The only exception to that rule is: when the home uniform color of the host team matches the guests' uniform, the host team puts on its guest uniform as well. For each team the color of the home and guest uniform is different.

There are *n* teams taking part in the national championship. The championship consists of *n*·(*n* - 1) games: each team invites each other team to its stadium. At this point Manao wondered: how many times during the championship is a host team going to put on the guest uniform? Note that the order of the games does not affect this number.

You know the colors of the home and guest uniform for each team. For simplicity, the colors are numbered by integers in such a way that no two distinct colors have the same number. Help Manao find the answer to his question.
The first line contains an integer *n* (2 ≤ *n* ≤ 30). Each of the following *n* lines contains a pair of distinct space-separated integers *h*<sub class="lower-index">*i*</sub>, *a*<sub class="lower-index">*i*</sub> (1 ≤ *h*<sub class="lower-index">*i*</sub>, *a*<sub class="lower-index">*i*</sub> ≤ 100) — the colors of the *i*-th team's home and guest uniforms, respectively.
n = int(input())

def count_games():
    uniforms = []

    #Get the uniform colors for each team:
    for i in range(1, n+1):
        #multi-variable to assign two consecutive integers to home and guest
        home, guest = map(int, input().split())     #applies int function to every element in the list and splits integers into separate items
        uniforms.append((home, guest))
    
    # Count the number of games where the host team plays in the guest uniform:
    count = 0
    for h in range(n): # n+1 is not used because in lists, the numbering of items starts from 0
        for a in range(n):
            print(f"h: {h}, a: {a}, uniforms[h]: {uniforms[h]}, uniforms[a]: {uniforms[a]}")
            print(f"uniforms[h][0]: {uniforms[h][0]}, uniforms[a][1]: {uniforms[a][1]}\n")
            if h != a and uniforms[h][0] == uniforms[a][1]:
                count += 1
            # "h != a" makes sure that the teams being compared are not the same
            # the first [] allows to access the first sublist in the list, and the second [] chooses the home/away kit number
    
    print(count)

count_games()