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