#include <bits/stdc++.h>
using namespace std;
void sober() {
  long long int n, x = 0, a = 0, b = 0, y = 0, sum = 0, k = 0, m = 0, c = 0,
                   d = 0;
  cin >> n;
  n *= 2;
  std::vector<long long int> v(n);
  long long int ans = 0;
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 1, j = 0; i < n; i += 2) {
    for (j = i; j < n; j++) {
      if (v[j] == v[i - 1]) {
        break;
      }
    }
    for (; j > i; j--) {
      ans++;
      swap(v[j], v[j - 1]);
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    sober();
  }
}
