#include <bits/stdc++.h>
using namespace std;
const int maxn = 102;
int ar[maxn], ans;
int main() {
  int n;
  cin >> n;
  n = 2 * n;
  for (int i = 1; i <= n; i++) cin >> ar[i];
  for (int i = 1; i <= n; i++)
    if (ar[i - 1] != ar[i] && ar[i + 1] != ar[i]) {
      int j = i + 1;
      while (ar[j] != ar[i] && j <= n) j++;
      for (int o = j; o > i + 1; o--) swap(ar[o], ar[o - 1]), ans++;
    }
  cout << ans << endl;
}
