#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T t) {
  return t < 0 ? -t : t;
}
const long long modn = 1000000007;
inline long long mod(long long x) { return x % modn; }
const int MAXN = 212345;
int n, m, k;
int s[MAXN];
int main() {
  scanf("%d", &n);
  for (int a = 0; a < 2 * n; a++) {
    scanf("%d", s + a);
  }
  int res = 0;
  for (int a = 0; a < 2 * n; a += 2) {
    for (int b = a + 1; b < 2 * n; b++) {
      if (s[a] == s[b]) {
        int bb = b;
        while (bb > a + 1) {
          res++;
          swap(s[bb], s[bb - 1]);
          bb--;
        }
        break;
      }
    }
  }
  printf("%d\n", res);
}
