#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> p;
int not_ok() {
  int last = p[0];
  for (unsigned int i = 1; i < p.size(); i++) {
    if (i % 2 == 1) {
      if (last != p[i]) return i - 1;
    } else {
      last = p[i];
    }
  }
  return -1;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  p.resize(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    cin >> p[i];
  }
  int cnt = 0, nok;
  while ((nok = not_ok()) != -1) {
    int target = p[nok];
    auto it = find(p.begin() + nok + 1, p.end(), target);
    int len = (it - p.begin()) - 1 - nok;
    for (int i = nok + len; i >= nok + 1; i--) {
      p[i + 1] = p[i];
    }
    p[nok + 1] = target;
    cnt += len;
  }
  cout << cnt;
  return 0;
}
