#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, a[300];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9);
  cin >> n;
  for (int i = 0; i < 2 * n; ++i) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    int now = a[i];
    for (int j = i + 1; j < 2 * n; ++j)
      if (a[j] == now) {
        ans += j - (i + 1);
        for (int k = j - 1; k >= i + 1; --k) a[k + 1] = a[k];
        a[i + 1] = now;
        break;
      }
  }
  cout << ans << '\n';
}
