#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  signed long long n;
  cin >> n;
  signed long long a[2 * n + 3];
  for (signed long long i = 0; i < 2 * n; i++) cin >> a[i];
  signed long long ct = 0;
  for (signed long long i = 0; i < 2 * n; i = i + 2) {
    for (signed long long j = i + 2; j < 2 * n; j++) {
      if (a[i] == a[j]) {
        signed long long k = j;
        while (a[i] != a[i + 1]) {
          swap(a[k], a[k - 1]);
          k--;
          ct++;
        }
        break;
      }
    }
  }
  cout << ct << endl;
  return 0;
}
