#include <bits/stdc++.h>
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
const int N = 100;
int tab[2 * N + 1];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (long long i = (long long)0; i < (long long)2 * n; i++) {
    cin >> tab[i];
  }
  int res = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    int k = tab[i];
    for (long long j = (long long)i + 1; j < (long long)2 * n; j++) {
      if (tab[j] == k) {
        while (j > i + 1) {
          swap(tab[j], tab[j - 1]);
          res++;
          j--;
        }
        break;
      }
    }
  }
  cout << res << "\n";
  return 0;
}
