#include <bits/stdc++.h>
using namespace std;
int a[300], n, ans;
bool bol[300];
int main() {
  scanf("%d", &n);
  n *= 2;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1, F = 0; i <= n; ++i) {
    if (bol[a[i]]) continue;
    for (int j = i + 1; j <= n; ++j) {
      if (a[j] == a[i]) {
        F = j;
        break;
      }
    }
    for (int j = F; j > i + 1; --j) swap(a[j], a[j - 1]), ++ans;
    bol[a[i]] = 1;
  }
  printf("%d", ans);
  return 0;
}
