#include <bits/stdc++.h>
using namespace std;
int qwq[205], a[205];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    scanf("%d", &qwq[i]);
    a[qwq[i]] = i;
  }
  int ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (a[qwq[i]] > i + 1) {
      for (int j = i + 1; j < a[qwq[i]]; j++) {
        if (a[qwq[j]] > a[qwq[i]]) ans--;
      }
      ans += a[qwq[i]] - i - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
