#include <bits/stdc++.h>
using namespace std;
vector<int> v(202);
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, con = 0, sgte;
  scanf("%d", &n);
  int l = 2 * n;
  for (int i = 0; i < l; ++i) scanf("%d", &v[i]);
  for (int i = 0; i < l; i += 2) {
    sgte = i + 1;
    while (v[i] != v[sgte]) sgte++;
    for (int j = sgte; j > i + 1; --j) {
      swap(v[j], v[j - 1]);
      con++;
    }
  }
  printf("%d\n", con);
  return 0;
}
