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