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