#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= 2 * n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 1; i <= 2 * n; i += 2) {
    for (int j = i + 1; j <= 2 * n; j++) {
      if (a[j] == a[i]) {
        ans += j - i - 1;
        for (int k = j; k > i; k--) swap(a[k], a[k - 1]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
