#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int a[301], n, u[300], ans;
int main() {
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
    if (u[a[i]]) {
      for (int j = i - 1; j > -1; j--) {
        if (a[j] == a[j + 1]) break;
        swap(a[j], a[j + 1]), ans++;
      }
    } else
      u[a[i]] = 1;
  }
  cout << ans << '\n';
}
