#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long n, ans = 0;
  cin >> n;
  vector<long long> a(2 * n);
  for (long long &i : a) cin >> i;
  for (long long i = 0; i < 2 * n; i += 2) {
    for (long long j = 2 * n; j > i + 1; j--) {
      if (a[i] == a[j]) {
        swap(a[j - 1], a[j]);
        ans++;
      }
    }
  }
  cout << ans;
}
