#include <bits/stdc++.h>
using namespace std;
const double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
const long long MOD = 1e9 + 7;
const long long INF = 1e17;
long long mpow(long long a, long long b) {
  a = a % MOD;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b = b >> 1;
  }
  return res % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long a[2 * n];
  for (int i = 0; i < (int)(2 * n); ++i) cin >> a[i];
  long long ans = 0;
  for (long long i = 0; i < 2 * n; i += 2) {
    long long j;
    for (j = i + 1; j < 2 * n; j++) {
      if (a[i] == a[j]) break;
    }
    while (j != i + 1) {
      swap(a[j], a[j - 1]);
      j--;
      ans++;
    }
  }
  cout << ans;
  return 0;
}
