#include <bits/stdc++.h>
using namespace std;
long long chk[300], ara[300];
int main() {
  long long n;
  scanf("%lld", &n);
  memset((chk), (-1), sizeof(chk));
  for (long long i = 1; i <= 2 * n; i++) {
    scanf("%lld", &ara[i]);
    chk[ara[i]] = i;
  }
  long long ans = 0;
  for (long long i = 1; i <= 2 * n; i = i + 2) {
    for (long long j = chk[ara[i]] - 1; j > i; j--) {
      long long sp = ara[j];
      ara[j + 1] = sp;
      if (chk[sp] == j) chk[sp]++;
    }
    ans += chk[ara[i]] - 1 - i;
  }
  cout << ans << endl;
}
