#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 res = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (a[i] == a[i - 1] || a[i] == a[i + 1]) continue;
    int next = -1;
    for (int j = i + 1; j <= 2 * n; j++)
      if (a[j] == a[i]) next = j;
    for (int j = next; j >= i + 2; j--) {
      swap(a[j], a[j - 1]);
      res++;
    }
  }
  printf("%d", res);
  return 0;
}
