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