#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[2 * n], ans = 0;
  for (int i = 0; i <= 2 * n - 1; i++) cin >> a[i];
  for (int i = 0; i < 2 * n; i += 2) {
    int j = i + 1;
    while (a[j] != a[i]) j++;
    ans += j - i - 1;
    for (int k = j; k >= i + 2; k--) a[k] = a[k - 1];
  }
  cout << ans;
  return 0;
}
