#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  n *= 2;
  vector<int> v(n);
  for (auto &x : v) cin >> x;
  int ans = 0;
  for (int i = 0; i < n - 1; i += 2) {
    for (int j = n - 1; j > (i + 1); j--) {
      if (v[j] == v[i]) {
        ans++;
        swap(v[j], v[j - 1]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
