#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count = 0;
  cin >> n;
  std::vector<int> a(2 * n);
  std::vector<int> dist(n + 1, -1);
  for (int i = 0; i < 2 * n; ++i) {
    cin >> a[i];
    if (dist[a[i]] == -1) {
      dist[a[i]] = i;
    } else {
      int distance = dist[a[i]];
      for (int k = i - 1; k > distance; --k) {
        swap(a[k + 1], a[k]);
        dist[a[k + 1]]++;
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
