#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > pq;
int n, a[205], res, d;
bool ok[1005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  d = n << 1;
  for (int i = 0; i < d; i++) cin >> a[i];
  for (int i = 0; i < d; i += 2) {
    if (!ok[a[i]]) {
      ok[a[i]] = true;
      for (int j = i + 1; j < d; j++) {
        if (a[j] == a[i]) {
          for (int k = j; k > i + 1; k--) {
            swap(a[k], a[k - 1]);
            res++;
          }
          break;
        }
      }
    }
  }
  cout << res;
  return 0;
}
