#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int n, a[N];
int main() {
  long long ans = 0;
  cin >> n;
  n = n * 2;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      int x = a[i];
      for (int j = i + 1; j <= n; j++) {
        if (a[j] == x) {
          for (int p = j; p > i; p--) {
            a[p] = a[p - 1];
          }
          ans += j - (i + 1);
        }
      }
    }
  }
  cout << ans;
  return 0;
}
