#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> input(2 * n);
  int visited[n + 1];
  vector<pair<int, int> > process;
  for (int i = 0; i <= n; i++) visited[i] = 0;
  for (int i = 0; i < 2 * n; i++) {
    cin >> input[i];
    if (!visited[input[i]]) process.push_back(make_pair(i, input[i]));
    visited[input[i]] = 1;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int temp = process[i].second;
    int index;
    for (int j = i * 2 + 1; j < 2 * n; j++)
      if (input[j] == temp) {
        index = j;
        break;
      }
    for (int j = index; j > i * 2 + 1; j--) {
      swap(input[j], input[j - 1]);
      ans++;
    }
  }
  cout << ans << endl;
}
