#include <bits/stdc++.h>
constexpr bool local = false;
using namespace std;
template <typename... Args>
void dbg(Args... args) {
  if (local) {
    fprintf(stderr, args...);
  }
}
int gInt() {
  int i;
  scanf("%d", &i);
  return i;
}
long long int gLong() {
  long long int i;
  scanf("%lld", &i);
  return i;
}
double gDouble() {
  double i;
  scanf("%lf", &i);
  return i;
}
void init() {}
void quit() {
  fclose(stdin);
  fclose(stdout);
  fclose(stderr);
  exit(0);
}
void body(int argc, char** argv);
int main(int argc, char** argv) {
  init();
  body(argc, argv);
  quit();
  return 0;
}
int n;
vector<int> pos;
vector<bool> used;
void body(int argc, char** argv) {
  n = gInt();
  for (int i = 0; i < 2 * n; ++i) {
    pos.push_back(gInt() - 1);
    used.push_back(false);
  }
  int ans = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (used[i]) {
      continue;
    }
    used[i] = true;
    int swaps = 0;
    for (int j = i + 1; j < 2 * n; ++j) {
      if (pos[j] == pos[i]) {
        used[j] = true;
        break;
      }
      if (!used[j]) {
        ++swaps;
      }
    }
    ans += swaps;
  }
  printf("%d\n", ans);
}
