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