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