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