#include <bits/stdc++.h>
using namespace std;
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
long long add(long long a, long long b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
long long binary_expo(long long base, long long expo) {
  long long res = 1;
  while (expo) {
    if (expo % 2) {
      res = mul(res, base);
    }
    expo /= 2;
    base = mul(base, base);
  }
  return res;
}
long long A[202];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= 2 * n; i++) {
    cin >> A[i];
  }
  long long ans = 0;
  for (long long i = 1; i <= 2 * n; i += 2) {
    long long index = -1;
    for (long long j = i + 1; j <= 2 * n; j++) {
      if (A[i] == A[j]) {
        index = j;
        break;
      }
    }
    for (long long j = index - 1; j >= i + 1; j--) {
      swap(A[j], A[j + 1]);
      ans++;
    }
  }
  cout << ans << '\n';
}
signed main() {
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
