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