#include <bits/stdc++.h>
using namespace std;
int n, a[212], ans;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < 2 * n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < 2 * n; i += 2) {
    if (a[i] != a[i + 1]) {
      int d = 0;
      for (int j = i + 1; j < 2 * n; ++j) {
        if (a[j] == a[i]) {
          d = j;
          break;
        }
      }
      for (int j = d; j > i + 1; --j) {
        swap(a[j], a[j - 1]);
        ++ans;
      }
    }
  }
  cout << ans;
}
