#include <bits/stdc++.h>
int n, a[205];
int main() {
  scanf("%d", &n);
  n <<= 1;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  int ans = 0;
  for (int i = 1; i < n; i += 2) {
    int p = -1;
    for (int j = i + 1; j <= n && p < 0; j++)
      if (a[j] == a[i]) p = j;
    while (p > i + 1) std::swap(a[p], a[p - 1]), --p, ans++;
  }
  printf("%d\n", ans);
  return 0;
}
