#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double Pi = acos(-1);
using namespace std;
int debug = 01;
void solve() {
  int n, ans = 0;
  cin >> n;
  n *= 2;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i += 2) {
    if (a[i] == a[i + 1]) continue;
    int p;
    for (int j = i + 2;; j++)
      if (a[j] == a[i]) {
        p = j;
        break;
      }
    for (int j = p; j > i + 1; j--) {
      swap(a[j], a[j - 1]);
      ans++;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tst = 1;
  for (int T = 1; T <= tst; T++) {
    solve();
  }
}
