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