#include <bits/stdc++.h>
using namespace std;
long long int poww(long long int x, long long int y) {
  long long int res = 1;
  x %= 1000000007;
  for (; y; y >>= 1) {
    if (y & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
  }
  return res;
}
int arr[100005];
int main() {
  int n;
  cin >> n;
  int arr[2 * n + 1];
  for (int i = 1; i <= 2 * n; i++) cin >> arr[i];
  long long int ans = 0;
  for (int i = 2; i <= 2 * n; i++) {
    if (arr[i] != arr[i - 1]) {
      for (int j = i + 1; j <= 2 * n; j++) {
        if (arr[j] == arr[i - 1]) {
          for (int k = j; k >= i + 1; k--) {
            swap(arr[k], arr[k - 1]);
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
