#include <bits/stdc++.h>
using namespace std;
void print(int x) { cerr << x; }
void print(long long x) { cerr << x; }
void print(double x) { cerr << x; }
void print(char x) { cerr << x; }
void print(string x) { cerr << x; }
template <class T>
void print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void print(map<T, V> v) {
  cerr << endl << "[ \n";
  for (auto i = v.begin(); i != v.end(); i++) {
    print(i->first);
    cerr << " ";
    print(i->second);
    cerr << endl;
  }
  cerr << "]";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1, i, ans = 0;
  cin >> t;
  vector<int> v(2 * t);
  for (i = 0; i < 2 * t; i++) cin >> v[i];
  for (int j = 0; j < 2 * t; j += 2) {
    if (v[j] == v[j + 1]) continue;
    int indx;
    for (i = j + 1; i < 2 * t; i++) {
      if (v[i] == v[j]) {
        indx = i;
        break;
      }
    };
    while (v[j] != v[j + 1]) {
      swap(v[indx - 1], v[indx]);
      indx--;
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
