#include <bits/stdc++.h>
const int md = 1e9 + 7;
using namespace std;
int main() {
  int n;
  cin >> n;
  n *= 2;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n - 2; i++) {
    if (a[i] != a[i + 1]) {
      int j = i + 2;
      for (; j < n; j++) {
        if (a[j] == a[i]) break;
      }
      ans += j - i - 1;
      for (int ii = j; ii >= i + 2; ii--) {
        a[ii] = a[ii - 1];
      }
    }
    i++;
  }
  cout << ans;
}
