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