#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < 2 * n; i++) cin >> a[i];
    int cnt = 0;
    for (int i = 0; i < 2 * n; i = i + 2) {
      if (a[i] != a[i + 1]) {
        for (int j = i + 2; j < 2 * n; j++) {
          if (a[i] == a[j]) {
            for (int k = j; k > i + 1; k--) {
              swap(a[k], a[k - 1]);
              cnt++;
            }
            break;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
