#include <bits/stdc++.h>
using namespace std;
template <class T>
void rd(vector<T> &a) {
  for (long long i = 0; i < a.size(); i++) cin >> a[i];
  return;
}
const long long MAXN = 2e5;
long long a[200];
bool check(long long first) {
  for (long long i = 0; i < first / 2; i += 2)
    if (a[i] != a[i + 1]) return 0;
  return 1;
}
void solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i < 2 * n; ++i) cin >> a[i];
  long long ans = 0;
  while (!check(2 * n)) {
    for (long long i = 0; i < 2 * n - 1; i += 2) {
      if (a[i] != a[i + 1]) {
        long long p = find(a + i + 1, a + 2 * n, a[i]) - a;
        for (long long j = p - 1; j > i; --j) {
          swap(a[j + 1], a[j]);
          ++ans;
        }
      }
    }
  }
  cout << ans;
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
