#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void MIN(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void MAX(T &a, T b) {
  if (a < b) a = b;
}
const int N = 105;
int n;
vector<int> v;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  int ans = 0;
  for (unsigned i = 0; i < v.size(); i++) {
    for (unsigned j = i + 1; j < v.size(); j++) {
      if (v[i] == v[j]) {
        ans += j - i - 1;
        v.erase(v.begin() + j);
        v.erase(v.begin() + i);
        i--;
        break;
      }
    }
  }
  printf("%d\n", ans);
}
