#include <bits/stdc++.h>
using namespace std;
long long n, k, mn, steps;
int main() {
  cin >> n;
  vector<int> a(2 * n), b(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < 2 * n; i++) {
    for (int x = i + 1; x < 2 * n; x++) {
      if (a[x] == a[i]) {
        k = x;
        break;
      }
    }
    int j = k;
    while (a[j] != a[j - 1] && j > 0) {
      swap(a[j], a[j - 1]);
      j--;
      steps++;
    }
    i++;
  }
  cout << steps << endl;
  return 0;
}
