#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  int p[2 * n];
  int pos[n][2], dis[n];
  int mstp = 0;
  int temp, currloc;
  for (i = 0; i < n; i++) {
    pos[i][0] = -1;
    pos[i][1] = -1;
  }
  for (i = 0; i < 2 * n; i++) {
    cin >> p[i];
    if (pos[p[i] - 1][0] == -1) {
      pos[p[i] - 1][0] = i;
    } else {
      pos[p[i] - 1][1] = i;
    }
  }
  for (i = 0; i < 2 * n; i++) {
    if (p[i] == p[i + 1])
      i = i + 1;
    else {
      currloc = pos[p[i] - 1][1];
      while (currloc > (i + 1)) {
        temp = p[currloc];
        if (pos[p[currloc - 1] - 1][0] == currloc - 1) {
          pos[p[currloc - 1] - 1][0] = currloc;
        } else
          pos[p[currloc - 1] - 1][1] = currloc;
        p[currloc] = p[currloc - 1];
        p[currloc - 1] = temp;
        mstp++;
        currloc--;
      }
      i = i + 1;
    }
  }
  cout << mstp;
  return 0;
}
