#include <bits/stdc++.h>
using namespace std;
bool check(vector<int> &A) {
  for (int i = 0; i < A.size(); i = i + 2) {
    if (A[i] != A[i + 1]) return false;
  }
  return true;
}
int fnd(int x, int i, vector<int> &A) {
  for (; i < A.size(); i++) {
    if (A[i] == x) return i;
  }
}
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  n = 2 * n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  int c = 0;
  int i = 0;
  while (!check(A)) {
    if (A[i] != A[i + 1]) {
      int k = fnd(A[i], i + 1, A);
      while (i + 1 < k) {
        swap(A[k], A[k - 1]);
        k--;
        c++;
      }
    }
    i = i + 2;
  }
  cout << c << endl;
  return 0;
}
