#include <bits/stdc++.h>
using namespace std;
long long n, arr[1000005];
int main() {
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    int j;
    for (j = i + 1; j < n; ++j) {
      if (arr[i] == arr[j]) {
        break;
      }
    }
    for (int x = j - 1; x > i; x--) {
      swap(arr[x], arr[x + 1]);
      ans++;
    }
  }
  cout << ans << endl;
}
