#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, a[202], vis[102], p, ans = 0, x;
  memset(vis, 0, sizeof(vis));
  cin >> n;
  for (int i = 1; i <= 2 * n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (vis[a[i]]) continue;
    p = a[i];
    for (int j = i + 1; j <= 2 * n; j++) {
      if (a[j] == p) {
        x = j;
        break;
      }
    }
    while (x != i + 1) {
      swap(a[x], a[x - 1]);
      ans++;
      x--;
    }
    vis[a[i]] = 1;
  }
  cout << ans << "\n";
  return 0;
}
