#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 7;
const int INF = 0x3f3f3f3f;
int n;
int ar[N];
int main(int argc, char const *argv[]) {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= 2 * n; ++i) {
      scanf("%d", &ar[i]);
    }
    int cnt = 0;
    for (int i = 1; i < 2 * n; ++i) {
      int p = -1;
      for (int j = i + 1; j <= 2 * n; j++) {
        if (ar[j] == ar[i]) {
          p = j;
          break;
        }
      }
      cnt += (p - (i + 1));
      for (int j = p; j > i + 1; --j) {
        ar[j] = ar[j - 1];
      }
      i++;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
