#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int pos[2 * n + 1];
  for (int i = 0; i < 2 * n; i++) cin >> pos[i + 1];
  int ans = 0;
  for (int i = 1; i < 2 * n + 1; i += 2) {
    if (pos[i] != pos[i + 1]) {
      int start, en;
      start = i + 1;
      for (int j = i + 1; j < 2 * n + 1; j++) {
        if (pos[i] == pos[j]) en = j;
      }
      for (int j = en; j >= start; j--) {
        pos[j] = pos[j - 1];
      }
      ans += en - start;
    }
  }
  cout << ans;
  return 0;
}
