#include <bits/stdc++.h>
using namespace std;
int p[100010];
int max(int a, int b) { return a > b ? a : b; }
int gcd(int x, int y) {
  int m;
  if (y == 0)
    m = x;
  else
    m = gcd(y, x % y);
  return m;
}
int find(int x) {
  int r = x;
  while (r != p[r]) r = p[r];
  int i = x, j;
  while (i != r) {
    j = p[i];
    p[i] = r;
    i = j;
  }
  return r;
}
int main() {
  int n;
  int a[1001];
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++) scanf("%d", &a[i]);
  int ans = 0;
  int i, j;
  for (i = 0; i < 2 * n; i += 2) {
    for (j = i + 1; j < 2 * n; j++)
      if (a[i] == a[j]) break;
    if (i == j - 1)
      continue;
    else {
      ans += j - i - 1;
      for (int k = j; k > i; k--) a[k] = a[k - 1];
    }
  }
  printf("%d\n", ans);
  return 0;
}
