#abc359b. B - Couples

B - Couples

Score : 150150 points

问题陈述

2N2N 个人排成一行,从左边数第 ii 个人穿着颜色为 AiA_i 的衣服。这里,衣服有 NN 种颜色,从 11NN,每种颜色恰好有两个人穿着。

找出有多少个整数 i=1,2,,Ni=1,2,\ldots,N 满足以下条件:

  • 在穿着颜色为 ii 的两个人之间恰好有一个人。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There are 2N2N people standing in a row, and the person at the ii-th position from the left is wearing clothes of color AiA_i. Here, the clothes have NN colors from 11 to NN, and exactly two people are wearing clothes of each color.

Find how many of the integers i=1,2,,Ni=1,2,\ldots,N satisfy the following condition:

  • There is exactly one person between the two people wearing clothes of color ii.

Constraints

  • 2N1002 \leq N \leq 100
  • 1AiN1 \leq A_i \leq N
  • Each integer from 11 through NN appears exactly twice in AA.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \ldots A2NA_{2N}

Output

Print the answer.

Sample Input 1

3
1 2 1 3 2 3

Sample Output 1

2

There are two values of ii that satisfy the condition: 11 and 33.

In fact, the people wearing clothes of color 11 are at the 1st and 3rd positions from the left, with exactly one person in between.

Sample Input 2

2
1 1 2 2

Sample Output 2

0

There may be no ii that satisfies the condition.

Sample Input 3

4
4 3 2 3 2 1 4 1

Sample Output 3

3