#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int bk[105];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    int tmp;
    scanf("%d", &tmp);
    v.push_back(tmp);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < v.size(); j++) bk[v[j]] = j;
    ans += bk[v[0]] - 1;
    v.erase(v.begin() + bk[v[0]]);
    v.erase(v.begin());
  }
  cout << ans << endl;
}
