#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  int a[2 * n];
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < 2 * n; i += 2) {
    int j;
    for (j = i; j < 2 * n; j++) {
      if (a[i - 1] == a[j]) {
        break;
      }
    }
    while (j > i) {
      swap(a[j], a[j - 1]);
      j--;
      ans++;
    }
  }
  cout << ans;
}
