#include <bits/stdc++.h>
using namespace std;
int n, a[205], pos[205], l[105], cnt;
bool vis[105];
int main() {
  scanf("%d", &n);
  memset(l, -1, sizeof(l));
  for (int i = 0; i < 2 * n; i++) {
    scanf("%d", &a[i]);
    if (!vis[a[i]])
      pos[i] = -1;
    else
      pos[i] = 1;
    vis[a[i]] = 1;
  }
  for (int T = 0; T < 10005; T++) {
    for (int i = 1; i < 2 * n; i++) {
      if (a[i] != a[i - 1] && pos[i - 1] == -1 && pos[i] == 1) {
        cnt++;
        swap(a[i], a[i - 1]);
        swap(pos[i], pos[i - 1]);
      }
    }
  }
  for (int i = 0; i < 2 * n; i += 2) {
    if (a[i] != a[i + 1]) {
      int ptr = i + 1;
      while (a[ptr] != a[i]) ptr++;
      cnt += ptr - i - 1;
      for (int j = ptr; j > i; j--) a[j] = a[j - 1];
      a[i + 1] = a[i];
    }
  }
  printf("%d\n", cnt);
}
