#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int arr[2 * maxn + 5], n, res;
int main() {
  cin >> n;
  for (int i = 1; i <= 2 * n; ++i) cin >> arr[i];
  for (int i = 1; i <= 2 * n; i += 2) {
    if (arr[i] == arr[i + 1]) continue;
    int number = arr[i], j = i + 1;
    for (; j <= 2 * n; ++j)
      if (arr[j] == number) break;
    for (int k = j; k > i + 1; --k) swap(arr[k], arr[k - 1]), ++res;
  }
  cout << res << endl;
  return 0;
}
