#include <bits/stdc++.h>
using namespace std;
vector<long long> v[102];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long a[2 * n];
  for (long long i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  long long an = 0;
  for (long long i = 0; i < 2 * n; i += 2) {
    if (a[i] == a[i + 1]) continue;
    long long id = i + 2;
    while (id < 2 * n && a[id] != a[i]) id++;
    for (long long j = id; j > i + 1; j--) {
      swap(a[j], a[j - 1]);
    }
    an += id - i - 1;
  }
  cout << an;
  return 0;
}
