#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 210;
int n, a[N];
pair<int, int> s[N];
void turn(int i, int j, int x, int y) {
  int pos1 = i, pos2 = j;
  if (s[x].first == i) {
    s[x].first = j;
  } else {
    s[x].second = j;
  }
  if (s[y].first == j) {
    s[y].first = i;
  } else {
    s[y].second = i;
  }
  swap(a[i], a[j]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) {
    s[i].first = 0;
    s[i].second = 0;
  }
  for (int i = 1; i < 2 * n + 1; i++) {
    scanf("%d", &a[i]);
    if (s[a[i]].first) {
      s[a[i]].second = i;
    } else {
      s[a[i]].first = i;
    }
  }
  int ans = 0;
  for (int i = 1; i < 2 * n + 1; i++) {
    if (a[i] != a[i + 1]) {
      int pos = s[a[i]].second + 1;
      for (int j = pos - 1; j >= i + 2; j--) {
        turn(j, j - 1, a[j], a[j - 1]);
        ans++;
      }
    }
    i++;
  }
  printf("%d", ans);
  return 0;
}
