#include <bits/stdc++.h>
using namespace std;
inline int gi() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return x * f;
}
template <typename T>
inline void Max(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
inline void Min(T &a, T b) {
  if (a > b) a = b;
}
const int N = 204;
int n, ans;
int a[N];
int main() {
  n = gi();
  n += n;
  for (int i = 1; i <= n; ++i) a[i] = gi();
  for (int i = 1; i <= n; i += 2) {
    int j = i + 1;
    for (; j <= n; ++j)
      if (a[j] == a[i]) break;
    ans += j - i - 1;
    for (; j > i; --j) swap(a[j], a[j - 1]);
  }
  printf("%d\n", ans);
  return 0;
}
