#include <bits/stdc++.h>
using namespace std;
int n, arr[202];
int ans = 0;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++) scanf("%d", &arr[i]);
  for (int i = 0; i < 2 * n; i += 2) {
    for (int j = i + 1; j < 2 * n; j++) {
      if (arr[i] == arr[j]) {
        for (int k = j; k >= i + 2; k--) swap(arr[k], arr[k - 1]);
        ans += (j - i - 1);
        break;
      }
    }
  }
  printf("%d", ans);
}
