#include <bits/stdc++.h>
using namespace std;
void solve(int input) {
  int n;
  cin >> n;
  int a[2 * n];
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (a[i] == a[i + 1]) {
      i++;
      continue;
    }
    for (int j = i + 1; j < 2 * n; j++) {
      if (a[i] == a[j]) {
        for (int k = j; k > i + 1; k--) {
          swap(a[k], a[k - 1]);
          ans++;
        }
        i++;
        break;
      }
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int x = 1;
  for (int i = 1; i <= x; i++) solve(i);
  return 0;
}
