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