#include <bits/stdc++.h>
using namespace std;
pair<long long int, long long int> b[105];
int main() {
  long long int n, i;
  cin >> n;
  long long int a[2 * n + 1], c = 0, j;
  for (i = 1; i <= 2 * n; i++) {
    cin >> a[i];
    if (b[a[i]].first == 0)
      b[a[i]].first = i;
    else
      b[a[i]].second = i;
  }
  for (i = 1; i <= 2 * n; i += 2) {
    c += b[a[i]].second - b[a[i]].first - 1;
    for (j = b[a[i]].second; j > i + 1; j--) {
      if (b[a[j - 1]].first == j - 1)
        b[a[j - 1]].first++;
      else
        b[a[j - 1]].second++;
      swap(a[j], a[j - 1]);
    }
  }
  cout << c;
  return 0;
}
