#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int ans, n, a[N << 1];
inline void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n << 1; i++) {
    scanf("%d", &a[i]);
  }
}
inline void solve() {
  for (int i = 1; i <= n << 1; i += 2) {
    for (int j = i + 1; j <= n << 1; j++) {
      if (a[i] == a[j]) {
        for (int k = j; k > i + 1; k--) {
          swap(a[k], a[k - 1]);
          ans++;
        }
      }
    }
  }
  printf("%d\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
