#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int a[N << 1];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n * 2; ++i) scanf("%d", a + i);
  int ans = 0, flag = 0;
  for (int i = 1; i <= n * 2; ++i) {
    if (flag == 0) {
      flag = a[i];
    } else {
      int id;
      for (int j = i; j <= n * 2; ++j)
        if (a[j] == flag) {
          id = j;
          break;
        }
      ans += id - i;
      for (int j = id; j >= i + 1; --j) a[j] = a[j - 1];
      a[i] = flag;
      flag = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
