#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[30], b[30];
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  int c = 0;
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < n; i++) {
      if (a[j] == b[i]) c++;
    }
  }
  cout << c << endl;
  return 0;
}
