#include <bits/stdc++.h>
using namespace std;
long double det(long double x, long double y, long double z, long double t) {
  return x * t - y * z;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, a[205], i, j, c = 0, x;
  cin >> n;
  for (i = 1; i <= n * 2; i++) cin >> a[i];
  for (i = 2; i <= 2 * n; i += 2) {
    if (a[i] != a[i - 1]) {
      for (j = i + 1; j <= 2 * n; j++) {
        if (a[j] == a[i - 1]) {
          x = j;
          break;
        }
      }
      for (long long int g = x; g > i; g--) {
        swap(a[g], a[g - 1]);
        c += 1;
      }
    }
  }
  cout << c;
  return 0;
}
