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