#include <bits/stdc++.h>
using namespace std;
long long int m, n, c, d, j, k, l, r, x, t, y, u, b, z, i, e, f, g, h;
int main() {
  cin >> n;
  long long int a[2 * n + 1];
  for (i = 1; i <= 2 * n; i++) cin >> a[i];
  for (i = 2; i <= 2 * n; i += 2) {
    for (j = i; j <= 2 * n; j++) {
      if (a[j] == a[i - 1]) break;
    }
    for (; j > i; j--) {
      swap(a[j], a[j - 1]);
      c++;
    }
  }
  cout << c;
}
