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