#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e17;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
long long ceil_div(long long a, long long b) { return (a + b - 1) / b; }
long long power(long long a, long long b) {
  if (b == 0) return 1;
  if (a == 1) return 1;
  long long x = power(a, b / 2);
  if (b % 2 == 0)
    return (x * x) % mod;
  else
    return (a * ((x * x) % mod)) % mod;
}
long long divide(long long a, long long b) {
  return a * power(b, mod - 2) % mod;
}
void solve() {
  long long n;
  cin >> n;
  long long arr[2 * n];
  for (long long i = 0; i < 2 * n; i++) cin >> arr[i];
  long long ans = 0;
  long long i = 0;
  while (i < 2 * n) {
    if (arr[i] == arr[i + 1]) {
      i += 2;
      continue;
    } else {
      for (long long j = i + 1; j < 2 * n; j++) {
        if (arr[i] == arr[j]) {
          ans += (j - i - 1);
          for (long long k = i + 1; k < j; k++) {
            long long temp = arr[k];
            arr[k] = arr[j];
            arr[j] = temp;
          }
          break;
        }
      }
      i += 2;
    }
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(15) << fixed;
  long long tc;
  tc = 1;
  while (tc--) {
    solve();
  }
}
