#include <bits/stdc++.h>
using namespace std;
const int N = 2e2 + 5;
int n;
int a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= 2 * n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 2; i < 2 * n; i += 2) {
    int j;
    for (j = i; j <= 2 * n; j++) {
      if (a[j] == a[i - 1]) break;
    }
    while (j > i) {
      swap(a[j], a[j - 1]);
      j--;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
