#include <bits/stdc++.h>
using namespace std;
int n, sum, a[100123];
int main() {
  cin >> n;
  int id = 0;
  for (int i = 1; i <= n * 2; i++) {
    cin >> a[i];
  }
  id++;
  while (id <= n * 2) {
    int b = 0;
    bool ok = 0;
    for (int i = id + 1; i <= n * 2; i++) {
      if (a[id] == a[i]) {
        b += i - id - 1;
        int d = a[i];
        for (int j = i - 1; j >= id + 1; j--) a[j + 1] = a[j];
        a[id + 1] = d;
        ok = 1;
      }
      if (ok == 1) break;
    }
    sum += b;
    id += 2;
  }
  cout << sum;
  return 0;
}
