#include <bits/stdc++.h>
using namespace std;
int n, t[205], res;
vector<int> v[205];
void print() {
  cout << endl;
  for (int i = 1; i <= n; i++) cout << t[i] << " ";
  cout << endl;
}
int main() {
  cin >> n;
  n *= 2;
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
    v[t[i]].push_back(i);
  }
  for (int i = 1; i <= n; i += 2) {
    int j = i + 1;
    while (t[i] != t[j]) j++;
    while (j != i + 1) {
      res++;
      swap(t[j], t[j - 1]);
      j--;
    }
  }
  cout << res;
}
