#include <bits/stdc++.h>
int main() {
  int count;
  std::vector<int> visitors;
  std::cin >> count;
  for (int i = 0; i < 2 * count; ++i) {
    int value;
    std::cin >> value;
    visitors.push_back(value);
  }
  int counter = 0;
  for (int i = 0; i < 2 * count; i += 2) {
    if (visitors[i] != visitors[i + 1]) {
      for (int j = 2 * count - 1; j > i + 1; j--) {
        if (visitors[j] == visitors[i]) {
          for (int k = j; k > i + 1; k--) {
            std::swap(visitors[k], visitors[k - 1]);
            counter++;
          }
          break;
        }
      }
    }
  }
  std::cout << counter << std::endl;
  return 0;
}
