#include <bits/stdc++.h>
using namespace std;
int ara[500];
int main() {
  int n;
  scanf("%d", &n);
  n *= 2;
  for (int i = 0; i < n; i++) scanf("%d", &ara[i]);
  long long ans = 0;
  for (int i = 0; i < n; i += 2) {
    int j = i + 1;
    for (j = i + 1; j < n; j++) {
      if (ara[j] == ara[i]) break;
    }
    while (j != i + 1) {
      swap(ara[j], ara[j - 1]);
      ans++;
      j--;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
