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