#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn];
bool vis[maxn];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  n <<= 1;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (vis[a[i]]) continue;
    for (int j = i + 1; j <= n; ++j) {
      if (a[j] == a[i]) {
        vis[a[j]] = true;
        break;
      }
      if (!vis[a[j]]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
