Typewriter Game

In the computer lab of IIITD, there is a typewriter with k keys.

Initially, all keys are unmarked. For example, when k=1, to type any character from the typewriter, you have to first mark the key with that character and then click on the key to type it. But to type another character using the same key, you first have to clear the alphabet which is marked on that key and mark it again with the different character you want to type. This whole clearing and marking it again is called a single clearance operation.

You are given a hypothetical dictionary consisting of n different characters which you can type by marking the character on any key of the typewriter.

You are also given an integer array a = [a1, a2, ..., an] where the i'th element represents the ai'th character in our hypothetical dictionary. You can assign any character to any key and then make a clearance operation in order to use the same key to type another character.

Your task is to determine minimum number of clearance operation needed to type the whole sequence in the order provided by the input array (a).

Note: The marking of any key for the first time is also considered as a clearance operation.

Input Format

First line contains two integers n (1 <= n <= 100000) and k(1 <= k <= 100000) - denoting the number of characters in the dictionary and number of keys in the typewriter.
Second line of input contains the array a (1 <= ai <= n).

Output Format

Output only one integer, the minimum number of clearance operations required.

Sample 0

Input

3 2
1 2 1

Output

2

Sample 1

Input

5 1
1 2 3 4 5

Output

5

Explanation

Let's consider the first sample test case. First, we will mark any one of the key with 1st character and type it, this will cost us one clearance operation. Then we will mark the remaining key with the 2nd character and type it, this is another clearance operation. But to type the 1st character once more, we don't need any clearance operation and we can use the original marked key to type it.

Time Limit
2000 ms
Memory Limit
262144 KiB
Please login to submit.
Ln: 1, Col: 1
Key Map: default
Login to submit.
Time: 25 May 2025, Sun 05:44:50
© 2025 UNIQUE BIT TECHNOLOGIES PVT. LTD. All Rights Reserved.