#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const long double eps = 1e-6;
const long long maxw = 1e17 + 10;
const int maxn = 2e2 + 10;
vector<int> pos[maxn];
int a[maxn];
int n;
bool isv[maxn];
bool f[maxn];
void solve() {
  int ans = 0;
  int res1, res2;
  for (int i = 1; i <= 2 * n; i++) {
    if (isv[a[i]]) continue;
    isv[a[i]] = 1;
    memset(f, 0, sizeof(f));
    res1 = pos[a[i]][0];
    res2 = pos[a[i]][1];
    if (res2 - res1 == 1) continue;
    ans += (res2 - res1 - 1);
    int j = i + 1;
    while (j < res2) {
      if (!f[a[j]]) {
        if (pos[a[j]][0] < res2) {
          pos[a[j]][0]++;
          f[a[j]] = 1;
        }
      } else {
        if (pos[a[j]][1] < res2) {
          pos[a[j]][1]++;
        }
      }
      j++;
    }
  }
  printf("%d\n", ans);
}
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= 2 * n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]].push_back(i);
  }
  solve();
  return 0;
}
