#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  n *= 2;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int counter = 0;
  for (int i = 0; i < n - 1; i += 2) {
    int pos;
    for (int y = i + 1; y < n; y++) {
      if (arr[y] == arr[i]) {
        pos = y;
        break;
      }
    }
    while (arr[pos - 1] != arr[i]) {
      swap(arr[pos], arr[pos - 1]);
      pos--;
      counter++;
    }
  }
  cout << counter << '\n';
  return 0;
}
