#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> v;
  copy_n(istream_iterator<int>(cin), 2 * n, back_inserter(v));
  int count = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    for (int j = i + 1; j < 2 * n; ++j) {
      if (v[i] == v[j]) {
        while (j != i + 1) {
          swap(v[j], v[j - 1]);
          j--;
          count++;
        }
        break;
      }
    }
  }
  cout << count << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
