#P9199. 「GMOI R2-T2」猫耳小
「GMOI R2-T2」猫耳小
Background
The difference between this problem and the enhanced version is the Constraints and the output format. In this version, , and the value range is . You do not need to output the construction.

Problem Description
Little R is a cute cat-eared girl. She likes studying the of sequences.
Now she has a sequence of length . She hates the integer , so she wants to modify some elements of into arbitrary natural numbers, so that the of every non-empty contiguous subarray of is not equal to .
Please find the minimum number of elements that need to be modified.
In this problem, the of a sequence is defined as the smallest natural number that does not appear in the sequence. For example:
- , because is a natural number.
- .
- .
Input Format
The first line contains two integers , representing the length of the sequence and the number that Little R hates.
The second line contains integers. The -th integer is , representing the -th term of the sequence.
Output Format
Output one integer in one line, representing the minimum number of elements to modify.
5 2
1 0 1 3 0
2
Hint
Sample Explanation
One possible way is to change into , modifying a total of two elements.
It can be proven that no better solution exists.
This problem uses Subtask bundled testdata.
| Subtask | Special Property | Corresponding Test Points | Total Score | |||
|---|---|---|---|---|---|---|
Special Property : It is guaranteed that .
For of the testdata, , .
Translated by ChatGPT 5