#include <bits/stdc++.h>
using namespace std;
void _print(bool t) { cerr << t; }
void _print(long long t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(double t) { cerr << t; }
template <class T>
void _print(vector<T> v) {
  cerr << "[  ";
  for (T i : v) {
    _print(i);
    cerr << "  ";
  }
  cerr << "]\n";
}
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << ", ";
  _print(p.second);
  cerr << "}";
}
template <class T>
void _print(set<T> v) {
  cerr << "[  ";
  for (T i : v) {
    _print(i);
    cerr << "  ";
  }
  cerr << "]\n";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[  ";
  for (T i : v) {
    _print(i);
    cerr << "  ";
  }
  cerr << "]\n";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[  ";
  for (auto i : v) {
    _print(i);
    cerr << "  ";
  }
  cerr << "]\n";
}
template <class T>
void _print(T v[], long long n) {
  cerr << "[  ";
  for (long long i = 0; i < n; i++) {
    _print(v[i]);
    cerr << "  ";
  }
  cerr << "]\n";
}
void run() {
  long long n;
  cin >> n;
  long long a[2 * n];
  for (long long i = 0; i < 2 * n; i++) cin >> a[i];
  long long ans = 0;
  for (long long i = 0; i < 2 * n; i += 2) {
    long long pos = i + 1;
    while (a[pos] != a[i]) pos++;
    ans += pos - i - 1;
    for (long long j = pos; j - 1 >= i; j--) swap(a[j], a[j - 1]);
  }
  cout << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie();
  long long t;
  t = 1;
  while (t--) {
    run();
  }
}
