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