#include <bits/stdc++.h>
using namespace std;
int countSwaps(vector<int> V) {
  if (V.size() == 0)
    return 0;
  else {
    int total = 0;
    int length = V.size();
    for (auto it = V.begin(); it != V.end(); it++) {
      if (*(it) == V[length - 1]) {
        total = V.end() - it - 2;
        V.erase(it);
        auto it2 = V.end();
        it2--;
        V.erase(it2);
        break;
      }
    }
    total = total + countSwaps(V);
    return total;
  }
}
int main() {
  int n;
  cin >> n;
  vector<int> V(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    cin >> V[i];
  }
  int answer = countSwaps(V);
  cout << answer << endl;
  return 0;
}
