#include <bits/stdc++.h>
using namespace std;
const long long INF = (1 << 30);
const long long inf = (1LL << 60LL);
const long long MOD = 1e9 + 7;
const int maxn = 1e5 + 5;
int n;
int arr[2015];
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (arr[i] == arr[j]) {
        for (int k = j; k > i + 1; k--) {
          swap(arr[k], arr[k - 1]);
          ret++;
        }
        break;
      }
    }
  }
  cout << ret << endl;
  return 0;
}
