#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[2 * n];
  int i;
  for (i = 0; i < 2 * n; i++) cin >> a[i];
  int left = 0, right = 2 * n - 1, count = 0;
  while (left < 2 * n) {
    if (a[left] != 0) {
      while (a[right] != a[left]) {
        right--;
      }
      a[right] = 0;
      while (right != left) {
        if (a[right] != 0) {
          count++;
        }
        right--;
      }
      right = 2 * n - 1;
    }
    left++;
  }
  cout << count;
}
