#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair<ll, ll>;
using vec = vector<ll>;
const int MOD = 1e9 + 7, N = 2222;
const ll LINF = LLONG_MAX;
ll a[N], b[N], n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (ll i = 1; i < n + 1; i++) {
    b[i] = -1;
  }
  for (ll i = 0; i < 2 * n; i++) {
    cin >> a[i];
    if (b[a[i]] == -1) {
      b[a[i]] = i;
    }
  }
  ll ans = 0;
  for (ll i = 0; i < 2 * n; i++) {
    for (ll j = 0; j < i; j++) {
      if (b[a[j]] > b[a[i]]) {
        ans++;
      }
    }
  }
  cout << ans;
  cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
  return 0;
}
