#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n;
  cin >> n;
  n *= 2;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0, j, cur, next, temp;
  for (int i = 0; i < n - 1; i += 2) {
    if (a[i] != a[i + 1]) {
      j = i + 1;
      cur = a[j];
      next = a[j + 1];
      while (next != a[i]) {
        temp = a[++j];
        a[j] = cur;
        next = a[j + 1];
        cur = temp;
        ans++;
      }
      a[++j] = cur;
      a[i + 1] = next;
      ans++;
    }
  }
  cout << ans;
  return 0;
}
