#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const double pi = acos(-1);
const int mod = 1e9 + 7;
long long fastpow(long long b, long long e) {
  if (!e) return 1;
  long long ret = fastpow(b, e / 2);
  ret = (ret * ret) % mod;
  if (e % 2) ret = (ret * b) % mod;
  return ret;
}
long long mi(int x) { return fastpow(x, mod - 2); }
int main() {
  int n;
  scanf("%d", &n);
  int a[205];
  for (int i = 0; i < 2 * n; i++) {
    scanf("%d", &a[i]);
  }
  int cntr = 0;
  while (1) {
    bool vis[105] = {0};
    int mx = 0, idx1 = -1, idx2 = -1;
    map<pair<int, int>, int> mp;
    for (int i = 0; i < 2 * n; i++) {
      if (vis[a[i]]) continue;
      vis[a[i]] = 1;
      int ii = i;
      for (int j = i + 1; j < 2 * n; j++) {
        if (a[j] != a[i]) {
          mp[{ii, j}]++;
          if (mp[{ii, j}] > mx) {
            mx = mp[{ii, j}];
            idx1 = i, idx2 = j;
          }
          ii++;
        } else {
          if (ii != i) {
            mp[{ii, j}]++;
            if (mp[{ii, j}] > mx) {
              mx = mp[{ii, j}];
              idx1 = i, idx2 = j;
            }
            ii++;
          }
          break;
        }
      }
    }
    if (!mx) {
      printf("%d\n", cntr);
      break;
    } else {
      cntr++;
      swap(a[idx1], a[idx2]);
    }
  }
  return 0;
}
