#include <bits/stdc++.h>
int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
using namespace std;
long long power(long long a, long long p, long long M) {
  long long r = 1;
  a = a % M;
  while (p > 0) {
    if (p % 2) r = (r * a) % M;
    a = (a * a) % M;
    p /= 2;
  }
  return r % M;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long n;
long long arr[(int)205];
void solve() {
  cin >> n;
  n = 2 * n;
  for (long long i = 0; i < n; i++) scanf("%lld", &arr[i]);
  ;
  set<long long> st;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (st.count(arr[i])) {
      for (long long j = 0; j < i; j++) {
        if (arr[j] == arr[i]) {
          for (long long k = i; k > j + 1; k--) {
            swap(arr[k], arr[k - 1]);
            ans++;
          }
          break;
        }
      }
    } else {
      st.insert(arr[i]);
    }
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
