#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MAXN = 1e3 + 69;
const long long MOD = 1e9 + 7;
const long long BASE = 13;
int n, indx, ans, arr[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < 2 * n; i++) cin >> arr[i];
  for (int i = 0; i < 2 * n; i += 2) {
    for (int j = 2 * n - 1; j > i; j--)
      if (arr[i] == arr[j]) indx = j;
    for (int j = indx - 1; j > i; j--) swap(arr[j + 1], arr[j]), ans++;
  }
  cout << ans;
  return cout << '\n', 0;
}
