#include <bits/stdc++.h>
using namespace std;
int N;
int A[210];
int main(void) {
  scanf("%d", &N);
  for (int i = 1; i <= 2 * N; i++) scanf("%d", A + i);
  int ans = 0;
  for (int i = 1; i <= 2 * N; i += 2) {
    int here = A[i];
    int pos;
    for (int j = i + 1; j <= 2 * N; j++)
      if (A[j] == here) pos = j;
    for (int j = pos; j > i + 1; j--) ans++, swap(A[j], A[j - 1]);
  }
  return 0 * printf("%d", ans);
}
