#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long LL_MAX = 9223372036854775807;
using namespace std;
int a[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++) scanf("%d", &a[i]);
  int ans = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (a[i] == 0) {
      continue;
    }
    if (a[i] != a[i + 1]) {
      int t = 0, j;
      for (j = i + 1; j < 2 * n && a[j] != a[i]; j++) {
        if (a[j] != 0) t++;
      }
      a[j] = 0;
      ans += t;
    } else
      i++;
  }
  printf("%d\n", ans);
  return 0;
}
