24
9 83
90 31
83 3
83 3
21 31
83 3
32 31
12 21
31 21
90 32
32 21
12 9
12 31
9 83
83 12
32 3
32 83
90 31
9 32
31 21
83 90
32 21
21 3
32 9
 25
91 57
2 73
54 57
2 57
23 57
2 6
57 54
57 23
91 54
91 23
57 23
91 57
54 2
6 91
57 54
2 57
57 91
73 91
57 23
91 57
2 73
91 2
23 6
2 73
23 6
 29
8 18
33 75
69 22
97 95
1 97
78 10
88 18
13 3
19 64
98 12
79 92
41 72
69 15
98 31
57 74
15 56
36 37
15 66
63 100
16 42
47 56
6 4
73 15
30 24
27 71
12 19
88 69
85 6
50 11
 30
67 21
85 39
85 87
21 39
66 85
10 95
10 21
87 85
82 21
67 21
95 10
21 39
82 21
21 66
66 39
95 30
67 85
66 82
85 82
21 66
10 39
67 10
21 85
10 82
85 95
10 85
21 39
85 39
39 10
95 67
 22
78 92
15 92
92 78
78 80
92 16
24 80
92 16
16 92
78 16
24 78
80 78
92 80
16 80
80 78
15 78
92 16
24 15
24 80
80 16
16 80
92 80
24 80
 29
80 27
69 80
27 80
69 80
80 27
80 27
80 27
80 69
27 69
80 69
80 27
27 69
69 27
80 69
27 69
69 80
27 69
80 69
80 27
69 27
27 69
27 80
80 27
69 80
27 69
80 69
69 80
69 80
27 80
 4
8 7
8 7
7 8
7 8
 30
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
 29
78 27
50 68
24 26
68 43
38 78
26 38
78 28
28 26
27 24
23 38
24 26
24 43
61 50
38 78
27 23
61 26
27 28
43 23
28 78
43 27
43 78
27 61
28 38
61 78
50 26
43 27
26 78
28 50
43 78
 10
68 42
1 35
25 70
59 79
65 63
46 6
28 82
92 62
43 96
37 28
 15
2 1
1 2
1 2
1 2
2 1
2 1
2 1
1 2
2 1
2 1
2 1
1 2
2 1
2 1
1 2
 30
100 99
58 59
56 57
54 55
52 53
50 51
48 49
46 47
44 45
42 43
40 41
38 39
36 37
34 35
32 33
30 31
28 29
26 27
24 25
22 23
20 21
18 19
16 17
14 15
12 13
10 11
8 9
6 7
4 5
2 3
 13
76 58
32 85
99 79
23 58
96 59
72 35
53 43
96 55
41 78
75 10
28 11
72 7
52 73
 12
1 2
1 2
1 2
1 2
1 2
1 2
2 1
2 1
2 1
2 1
2 1
2 1
 6
1 2
1 2
1 2
1 2
1 2
2 1
 30
19 71
7 89
89 71
21 7
19 21
7 89
19 71
89 8
89 21
19 8
21 7
8 89
19 89
7 21
19 8
19 7
7 19
8 21
71 21
71 89
7 19
7 19
21 7
21 19
21 19
71 8
21 8
71 19
19 71
8 21
 15
9 3
2 6
7 6
5 10
9 5
8 1
10 5
2 8
4 5
9 8
5 3
3 8
9 8
4 10
8 5
 30
10 39
89 1
78 58
75 99
36 13
77 50
6 97
79 28
27 52
56 5
93 96
40 21
33 74
26 37
53 59
98 56
61 65
42 57
9 7
25 63
74 34
96 84
95 47
12 23
34 21
71 6
27 13
15 47
64 14
12 77
 28
31 66
31 91
91 31
97 66
31 66
31 66
66 91
91 31
97 31
91 97
97 31
66 31
66 97
91 31
31 66
31 66
66 31
31 97
66 97
97 31
31 91
66 91
91 66
31 66
91 66
66 31
66 31
91 97
 30
46 100
87 53
34 84
44 66
23 20
50 34
90 66
17 39
13 22
94 33
92 46
63 78
26 48
44 61
3 19
41 84
62 31
65 89
23 28
58 57
19 85
26 60
75 66
69 67
76 15
64 15
36 72
90 89
42 69
45 35
 30
44 17
44 17
44 17
17 44
44 17
44 17
17 44
17 44
17 44
44 17
44 17
44 17
44 17
44 17
17 44
17 44
17 44
44 17
44 17
17 44
44 17
44 17
44 17
17 44
17 44
44 17
17 44
44 17
44 17
44 17
 2
46 6
6 46
 4
1 2
1 2
2 1
2 1
 18
6 90
100 79
26 100
67 100
29 100
100 32
94 88
18 58
59 65
51 56
64 68
34 2
6 98
95 82
34 2
40 98
83 78
29 100
 18
6 90
70 79
26 52
67 81
29 95
41 32
94 88
18 58
59 65
51 56
64 68
34 2
6 98
95 82
34 2
40 98
83 78
29 2
 23
43 78
31 28
58 80
66 63
20 4
51 95
40 20
50 14
5 34
36 39
77 42
64 97
62 89
16 56
8 34
58 16
37 35
37 66
8 54
50 36
24 8
68 48
85 33
 25
2 1
1 2
1 2
1 2
2 1
1 2
1 2
1 2
2 1
2 1
2 1
1 2
1 2
1 2
2 1
2 1
2 1
1 2
2 1
1 2
2 1
2 1
2 1
2 1
1 2
 7
4 7
52 55
16 4
55 4
20 99
3 4
7 52

59
 96
 10
 100
 74
 277
 8
 450
 73
 1
 108
 0
 0
 72
 10
 154
 20
 6
 210
 4
 418
 2
 8
 8
 1
 6
 312
 6

import java.io.*;
import java.util.*;

public class App {
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        String next() { // reads in the next string
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() { return Integer.parseInt(next()); } // reads in the next int
        public long nextLong() { return Long.parseLong(next()); } // reads in the next long
        public double nextDouble() { return Double.parseDouble(next()); } // reads in the next double
    }
    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) {
        // YOUR CODE HERE
        int length = r.nextInt();
        int distinct = 0;
        IntPair[] arr = new IntPair[length];
        for(int i=0; i<length; i++){
            arr[i] = new IntPair(r.nextInt(),r.nextInt());
        }
        for(int i=0; i<arr.length-1; i++){
            for(int j=1; j<arr.length; j++){
                if(i == j) continue;
                IntPair team1 = arr[i];
                IntPair team2 = arr[j];
                if(team1.x == team2.y){
                    distinct++;
                    continue;
                }
                if(team1.y == team2.x){
                    distinct++;
                    continue;
                };
            }
        }
        pw.println(distinct);
        pw.close(); // flushes the output once printing is done
    }
    static class IntPair {
        final int x;
        final int y;
        IntPair(int x, int y) {this.x=x;this.y=y;}
    }
}

//3
//1 2
//2 4
//3 4

//1.#1 and #2 home of #1
//2 #1 and #2 home of #2
//3 #1 and #3 home of #1
//4 #1 and #3 home of #3
//5 #2 and #3 home of #2
//6 #2 and #3 home of #3