#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int A[101];
int main() {
  int temp;
  int n, num = 0;
  scanf("%d", &n);
  for (int i = 1; i <= 2 * n; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 1; i <= 2 * n; i += 2) {
    for (int j = i + 1; i <= 2 * n; j++) {
      if (A[j] == A[i]) {
        int b = j;
        while (b != i + 1 && b >= 1) {
          temp = A[b - 1];
          A[b - 1] = A[b];
          A[b] = temp;
          b--;
          num++;
        }
        break;
      }
    }
  }
  printf("%d", num);
}
