#include <bits/stdc++.h>
using namespace std;
long long minswap(long long arr[], long long k, long long i) {
  long long ans = 0, j;
  if (i > (k - 2)) return 0;
  if (arr[i] == arr[i + 1]) return minswap(arr, k, i + 2);
  for (j = (i + 2); j < k; j++)
    if (arr[j] == arr[i]) break;
  for (long long a = j; a >= (i + 2); a--) {
    ans++;
    long long temp = arr[a];
    arr[a] = arr[a - 1];
    arr[a - 1] = temp;
  }
  return ans + minswap(arr, k, i + 2);
}
int main() {
  long long n, i, j, k;
  cin >> n;
  k = n * 2;
  long long arr[k];
  for (i = 0; i < k; i++) cin >> arr[i];
  j = minswap(arr, k, 0);
  cout << j << "\n";
  return 0;
}
