#include <bits/stdc++.h>
using namespace std;
int n, hitung, arr[212];
void swap(int x, int y) {
  for (int i = y; i > x; i--) {
    int tmp = arr[i - 1];
    arr[i - 1] = arr[i];
    arr[i] = tmp;
    hitung += 1;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= 2 * n; i++) {
    cin >> arr[i];
  }
  int i = 1;
  while (i <= 2 * n) {
    if (arr[i] == arr[i + 1]) {
    } else {
      for (int j = i + 2; j <= 2 * n; j++) {
        if (arr[i] == arr[j]) {
          swap(i + 1, j);
          break;
        }
      }
    }
    i += 2;
  }
  cout << hitung << "\n";
}
