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