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