#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const long long INF = 100000000000000LL;
const long long mod = 998244353;
int n;
int a[maxn];
void solve() {
  for (int i = 1; i <= 2 * n; i++) scanf("%d", &a[i]);
  int mk = -1;
  int ans = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (mk == -1)
      mk = a[i];
    else {
      if (mk == a[i])
        mk = -1;
      else {
        int pos;
        for (int j = i + 1; j <= 2 * n; j++) {
          if (a[j] == mk) {
            pos = j;
            break;
          }
        }
        ans += pos - i;
        for (int j = pos; j > i; j--) {
          a[j] = a[j - 1];
        }
        a[i] = mk;
        mk = -1;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (~scanf("%d", &n)) {
    solve();
  }
  return 0;
}
