#include <bits/stdc++.h>
using namespace std;
int arr[210];
int main() {
  int n, ans = 0;
  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;
    else {
      for (int j = i + 1; j <= 2 * n; j++) {
        if (arr[j] == arr[i]) {
          ans += j - i - 1;
          for (int k = j; k > i + 1; k--) {
            swap(arr[k], arr[k - 1]);
          }
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
