#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e4 + 10;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
const long long inf = 1e10;
int main() {
  int N;
  cin >> N;
  int a[2 * N];
  for (int i = 0; i < 2 * N; i++) cin >> a[i];
  int swps = 0;
  int i = 0;
  while (i < 2 * N) {
    if (a[i] != a[i + 1]) {
      int cnt = 0, j;
      for (j = 0; j < 2 * N; j++) {
        if (a[i] == a[j]) cnt++;
        if (cnt == 2) break;
      }
      swps += j - i - 1;
      int key = a[i + 1];
      while (j > i + 2) {
        a[j] = a[j - 1];
        j--;
      }
      a[i + 2] = key;
      a[i + 1] = a[i];
    }
    i += 2;
  }
  cout << swps << endl;
}
