#include <bits/stdc++.h>
using namespace std;
int n, a[220], b[220];
int findfr1(int x) {
  for (int i = 0; i < 2 * n; i++)
    if (a[i] == x) return x;
}
int findfr2(int x) {
  for (int i = 0; i < 2 * n; i++)
    if (b[i] == x) return x;
}
int findsc1(int x, int z) {
  for (int i = 0; i < 2 * n; i++)
    if (a[i] == x && i != z) return i;
}
int findsc2(int x) {
  bool check = false;
  for (int i = 0; i < 2 * n; i++)
    if (a[i] == x) {
      if (!check)
        check = true;
      else
        return x;
    }
}
int main() {
  int res = 0;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (int i = 0; i < 2 * n; i += 2) {
    int x = findsc1(a[i], i);
    while (x - 1 > i) {
      swap(a[x], a[x - 1]);
      x--;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}
