#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int a[205];
void run_case() {
  long long n, m = 1, ans, cnt = 0;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  for (int i = 0; i < 2 * n; i += 2) {
    for (int j = i + 1; j < 2 * n; j++) {
      if (a[j] == a[i]) {
        for (int k = j + 1 - 1; k >= i + 2; k--) swap(a[k], a[k - 1]), cnt++;
        break;
      }
    }
  }
  cout << cnt;
}
int main() {
  int T = 1, k = 1;
  while (T--) {
    run_case();
  }
  return 0;
}
