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