#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
int a[2500];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  n *= 2;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int ans = 0;
  for (int i = 1; i <= n;) {
    if (a[i] == a[i + 1]) {
      i += 2;
      continue;
    }
    int j;
    for (j = i + 1; j <= n; ++j)
      if (a[j] == a[i]) break;
    ans += j - (i + 1);
    for (int k = j; k > i; --k) a[k] = a[k - 1];
  }
  cout << ans;
  return 0;
}
