#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  vector<long long> v;
  for (long long i = 0; i < 2 * n; i++) {
    long long a;
    cin >> a;
    v.push_back(a);
  }
  long long ans = 0;
  auto i = v.begin();
  while (v.size() > 0) {
    long long k = 0;
    for (auto j = v.begin() + 1; j != v.end(); j++) {
      if (*j == v[0]) {
        ans += k;
        v.erase(j);
        v.erase(i);
        break;
      }
      k++;
    }
  }
  cout << ans;
}
int main() {
  long long tc = 1;
  while (tc--) {
    solve();
    cout << endl;
  }
}
