#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, x, y;
map<long long int, long long int> m2;
map<int, int> m3;
vector<int> v[400007];
long long int a, b, d;
long long int vis[400007];
vector<int> v2;
int m97;
void dfs(int x, int c, int max) {
  vis[x] = 1;
  if (v[x].size() == 1 && x != 1) {
    if (max == -1)
      max = c;
    else if (max < c)
      max = c;
    m97 = max;
    return;
  }
  for (int j = 0; j < v[x].size(); j++) {
    if (!vis[v[x][j]]) {
      dfs(v[x][j], c + 1, max);
      if (x == 1) {
        v2.push_back(m97);
        max = -1;
      }
    }
  }
}
int main() {
  cin >> n;
  vector<int> v(500, 0);
  for (int j = 0; j < 2 * n; j++) cin >> v[j];
  long long int c = 0;
  for (int j = 1; j < 2 * n; j += 2) {
    if (v[j] != v[j - 1]) {
      int i;
      for (i = j + 1; i < 2 * n; i++) {
        if (v[i] == v[j - 1]) break;
      }
      c += i - j;
      v.insert(v.begin() + j, v[j - 1]);
      v.erase(v.begin() + i + 1);
    }
  }
  cout << c;
}
