#include <bits/stdc++.h>
using namespace std;
int w[1000001];
int v[1000001];
int sum[100001];
int a[10000005];
int b[30];
map<int, int> m;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n * 2; i++) {
    cin >> a[i];
  }
  int sum = 0;
  int i, j;
  for (i = 2; i <= 2 * n; i += 2) {
    for (j = i; j <= 2 * n; j++) {
      if (a[j] == a[i - 1]) {
        break;
      }
    }
    for (j = j; j > i; j--) {
      int t;
      t = a[j];
      a[j] = a[j - 1];
      a[j - 1] = t;
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
