#include <bits/stdc++.h>
using namespace std;
pair<int, int> t[4] = {make_pair(0, 1), make_pair(1, 0), make_pair(-1, 0),
                       make_pair(0, -1)};
bool compare(long long int a, long long int b) { return (a < b); }
vector<int> a(203);
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> a[i];
  }
  long long int count = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    int k = a[i];
    int ind;
    for (int j = i + 1; j < 2 * n; j++) {
      if (a[j] == k) {
        ind = j;
        break;
      }
    }
    for (int j = ind; j > i + 1; j--) {
      int temp = a[j];
      a[j] = a[j - 1];
      a[j - 1] = temp;
      count++;
    }
  }
  cout << count << endl;
  ;
}
