#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 1e9 + 7;
const double eps = 1e-6;
const int base = 131;
const int MAXN = 2e2 + 7;
int n, res;
int a[MAXN];
int main() {
  scanf("%d", &n);
  n *= 2;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    int j = i + 1;
    while (a[i] != a[j] && j < n) j++;
    while (j != i + 1) {
      res++;
      swap(a[j], a[j - 1]);
      j--;
    }
    i++;
  }
  printf("%d\n", res);
  return 0;
}
