#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[2 * n], p[2 * n], c = 0;
  for (int i = 0; i < 2 * n; i++) cin >> a[i], p[i] = -1;
  for (int i = 0; i < 2 * n - 1; i++) {
    if (p[i] == -1)
      p[i] = 1;
    else
      continue;
    if (a[i] == a[i + 1]) {
      p[i] = 0, p[i + 1] = 0;
      continue;
    }
    for (int j = i + 1; j < 2 * n; j++) {
      if (a[j] == a[i]) p[j] = 2;
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    for (int j = 0; j < 2 * n - 1; j++) {
      if (a[j] == a[j + 1]) p[j] = p[j + 1] = 0;
      if (p[j] == 1 && (p[j + 1] == 0 || p[j + 1] == 2)) {
        swap(p[j], p[j + 1]);
        swap(a[j], a[j + 1]);
        c++;
      }
    }
  }
  cout << c;
  return 0;
}
