#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  long long arr[2 * n];
  for (long long i = 0; i < 2 * n; i++) cin >> arr[i];
  long long m = 0;
  for (long long i = 0; i < 2 * n; i++) {
    if (arr[i] != arr[i + 1]) {
      for (long long j = i + 1; j < 2 * n; j++) {
        if (arr[i] == arr[j]) {
          for (long long k = j; k > i + 1; k--) {
            swap(arr[k], arr[k - 1]);
            m++;
          }
          break;
        }
      }
      i++;
    } else
      i++;
  }
  cout << m;
}
