#include <bits/stdc++.h>
using namespace std;
long long int a[205], b[105], c[105];
int main() {
  long long int n, i, j, sum = 0;
  cin >> n;
  for (i = 1; i <= 2 * n; i++) cin >> a[i];
  for (i = 1; i <= 2 * n; i++) {
    memset(b, 0, sizeof(b));
    c[a[i]]++;
    if (c[a[i]] == 2) continue;
    for (j = i + 1; j <= 2 * n; j++)
      if (a[j] == a[i])
        break;
      else {
        b[a[j]]++;
        if (b[a[j]] == 2) sum += 2;
      }
    sum += (j - i) - 1;
  }
  cout << sum / 2;
}
