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