#include <bits/stdc++.h>
using namespace std;
int n, a[204];
int main() {
  cin >> n;
  int t;
  int ans = 0;
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  for (int i = 0; i < 2 * n; i += 2) {
    t = a[i];
    if (a[i + 1] == t) continue;
    int idx;
    for (int j = i + 2; j < 2 * n; j++)
      if (a[j] == t) idx = j;
    for (int j = idx; j > i + 1; j--) {
      swap(a[j], a[j - 1]);
      ans++;
    }
  }
  cout << ans;
  return 0;
}
