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