#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, flag, ans = 0;
  cin >> n;
  int arr[2 * n];
  for (int i = 0; i < (2 * n); i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < (2 * n); i += 2) {
    if ((i + 1) < (2 * n)) {
      if (arr[i] == arr[i + 1]) {
        continue;
      } else {
        for (int j = i + 1; j < (2 * n); j++) {
          int x = j;
          if (arr[i] == arr[x]) {
            while ((i + 1) != x && x >= 1) {
              flag = arr[x];
              arr[x] = arr[x - 1];
              arr[x - 1] = flag;
              ans++;
              x--;
            }
          }
        }
      }
    }
  }
  cout << ans;
  return 0;
}
