#include <bits/stdc++.h>
using namespace std;
int n;
int a[210];
int main() {
  cin >> n;
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  int zbr = 0;
  for (int i = 1; i < 2 * n; i += 2) {
    int p = i;
    while (a[p] != a[i - 1]) p++;
    while (p != i) {
      swap(a[p], a[p - 1]);
      p--;
      zbr++;
    }
  }
  cout << zbr;
  return 0;
}
