#include <bits/stdc++.h>
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
int a[105], vis[105];
vector<int> v[105];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 2 * n; ++i) cin >> a[i];
  int ans = 0;
  for (int i = 1; i <= 2 * n; ++i) {
    if (vis[a[i]]) continue;
    vis[a[i]] = 1;
    for (int j = i + 1; a[j] != a[i]; ++j)
      if (!vis[a[j]]) ++ans;
  }
  cout << ans << '\n';
}
