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