#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000;
int a[MAX_N];
int main() {
  int n, x;
  cin >> n;
  n *= 2;
  long long ans = 0;
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  for (int i = 0; i < 2 * n; i++) {
    x = -1;
    for (int j = i + 1; j < 2 * n; j++) {
      if (a[i] == a[j]) {
        x = j;
        break;
      }
    }
    for (int j = x; j > i + 1; j--) {
      a[j] = a[j - 1];
      ans++;
    }
  }
  cout << ans;
  return 0;
}
