#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int a[222];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    if (a[i] == a[i + 1]) continue;
    int pos;
    for (int j = i + 1; j < n * 2; j++) {
      if (a[j] == a[i]) {
        pos = j;
        break;
      }
    }
    for (int j = pos; j > i + 1; j--) {
      a[j] = a[j - 1];
      ans++;
    }
    a[i + 1] = a[i];
  }
  cout << ans;
}
