#include <bits/stdc++.h>
using namespace std;
int n, ans = 0, a[205];
inline int read() {
  int red = 0, f_f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f_f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') red = red * 10 + ch - '0', ch = getchar();
  return red * f_f;
}
int main() {
  n = read() * 2;
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i += 2) {
    int pos = 0;
    for (int j = i + 1; j <= n; j++)
      if (a[j] == a[i]) {
        pos = j;
        break;
      }
    for (int j = pos; j > i; j--) a[j] = a[j - 1];
    ans += pos - i - 1;
  }
  printf("%d\n", ans);
  return 0;
}
