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