#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int i, n, arr[205], j, ans = 0;
  cin >> n;
  for (i = 1; i <= 2 * n; i++) {
    cin >> arr[i];
  }
  for (i = 2; i <= 2 * n; i += 2) {
    for (j = i; j <= 2 * n; j++) {
      if (arr[j] == arr[i - 1]) break;
    }
    for (; j > i; j--) {
      swap(arr[j - 1], arr[j]);
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
