#include <bits/stdc++.h>
using namespace std;
double const pi = 3.1415926536;
int const N = 1000005;
int main() {
  int n;
  cin >> n;
  int a[2 * n];
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  long long ans = 0;
  int l = 0;
  while (l < 2 * n) {
    if (a[l] != a[l + 1]) {
      int pos;
      for (int i = l + 1; i < 2 * n; i++) {
        if (a[i] == a[l]) {
          pos = i;
          break;
        }
      }
      int cnt = 0;
      while (pos != l + 1) {
        swap(a[pos], a[pos - 1]);
        pos--;
        cnt++;
      }
      ans += cnt;
      l += 2;
    } else
      l += 2;
  }
  cout << ans;
}
