#include <bits/stdc++.h>
int n, ans, A[220];
short vis[220];
int main() {
  int i, j;
  scanf("%d", &n);
  n <<= 1;
  for (i = 1; i <= n; i++) scanf("%d", &A[i]);
  for (i = 1; i <= n; i++)
    if (!vis[i]) {
      for (j = i + 1; A[i] != A[j]; j++)
        if (!vis[j]) ans++;
      vis[i] = vis[j] = 1;
    }
  printf("%d\n", ans);
  return 0;
}
