#include <bits/stdc++.h>
using namespace std;
int n;
int dep[105];
int bel[105];
int li[205];
bool done[105];
int dum;
int main() {
  memset(done, 0, sizeof(done));
  memset(dep, -1, sizeof(dep));
  memset(bel, -1, sizeof(bel));
  scanf("%d", &n);
  for (int i = 1; i <= 2 * n; i++) {
    scanf("%d", &dum);
    if (dep[dum] == -1)
      dep[dum] = i;
    else
      bel[dum] = i;
    li[i] = dum;
  }
  int ans = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (done[li[i]]) continue;
    done[li[i]] = 1;
    ans += bel[li[i]] - i - 1;
    for (int j = bel[li[i]]; j >= i + 2; j--) {
      li[j] = li[j - 1];
      if (dep[li[j]] == j - 1)
        dep[li[j]] = j;
      else
        bel[li[j]] = j;
    }
    li[i + 1] = li[i];
  }
  printf("%d\n", ans);
  return 0;
}
