#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
template <typename X>
using matrix = vector<vector<X>>;
const ll INF = (ll)1e9 + 6ll;
const vector<int> DX = {+1, -1, 0, 0, +1, -1, -1, +1};
const vector<int> DY = {0, 0, +1, -1, +1, -1, +1, -1};
template <typename X>
bool soft(X& a, const X b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename X>
bool strong(X& a, const X b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void freeopen() {}
void speedforce() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
signed main() {
  freeopen();
  speedforce();
  int n;
  cin >> n;
  vector<int> a(n << 1);
  int i = 0;
  for (int& x : a) cin >> x;
  int ans = 0;
  for (int i = 0; i < (n << 1); i += 2) {
    int l = i;
    int r;
    for (int j = 0; j < (n << 1); j++)
      if (a[j] == a[i] && j != i) {
        r = j;
        break;
      }
    if (a[i] != a[i + 1]) {
      for (int j = r - 1; j > l; j--) swap(a[j], a[j + 1]);
      ans += r - l - 1;
    }
  }
  cout << ans;
  return false;
}
