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