P24768 [AtCoder] Couples
入门
题目描述

Problem Statement

There are 2N people standing in a row, and the person at the i-th position from the left is wearing clothes of color A_i. Here, the clothes have N colors from 1 to N, and exactly two people are wearing clothes of each color.
Find how many of the integers $i=1,2,\ldots,N$ satisfy the following condition:

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

Input

The input is given from Standard Input in the following format:
N
$A_1 A_2 \ldots A_{2N}$

Output

Print the answer.

Constraints

  • $2 \leq N \leq 100$
  • $1 \leq A_i \leq N$
  • Each integer from 1 through N appears exactly twice in A.
  • All input values are integers.

Sample Input 1

3
1 2 1 3 2 3

Sample Output 1

2

There are two values of i that satisfy the condition: 1 and 3.
In fact, the people wearing clothes of color 1 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 i that satisfies the condition.

Sample Input 3

4
4 3 2 3 2 1 4 1

Sample Output 3

3

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1 2 1 3 2 3
样例输出
2