#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(2 * n);
  for (long long i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long i = 0; i < 2 * n; i++) {
    for (long long j = i + 1; j < 2 * n; j++) {
      if (a[i] == a[j]) {
        while (j - i > 1) {
          swap(a[j], a[j - 1]);
          ans++;
          j--;
        }
        break;
      }
    }
  }
  cout << ans;
  return 0;
}
