#include <bits/stdc++.h>
using namespace std;
int n, a[200];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  n <<= 1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    int j = i + 1;
    for (; j < n; ++j) {
      if (a[j] == a[i]) break;
    }
    ans += j - i - 1;
    for (; j > i; --j) {
      a[j] = a[j - 1];
    }
  }
  cout << ans << '\n';
  return 0;
}
