#include <bits/stdc++.h>
using namespace std;
long long a[1010];
int main() {
  long long n, i, j, ans = 0, m, x, y, d, p1, p2;
  scanf("%lld", &n);
  for (i = 1; i <= 2 * n; i++) {
    scanf("%lld", &a[i]);
  }
  for (i = 1; i <= 2 * n; i++) {
    x = a[i];
    p1 = i;
    p2 = 0;
    for (j = i + 1; j <= 2 * n; j++) {
      if (a[j] == x) p2 = j;
    }
    if (p2 != 0) {
      d = (p2 - p1 - 1);
      ans += d;
      for (j = p2; j > i + 1; j--) a[j] = a[j - 1];
      a[i + 1] = a[i];
    }
  }
  cout << ans << endl;
}
