Problem
A person affiliated with JOI works at a toy store. Today, they have been assigned to organize the plush toy corner inside the store.
On the shelf of the plush toy corner, $N$ plush toys are lined up in a row from left to right. The shelf is divided by partitions into $N$ compartments, and $1$ plush toy is placed in $1$ compartment. This toy store sells a total of $M$ types of plush toys, which are numbered from $1$ to $M$, respectively. Each of the $N$ plush toys lined up on the shelf belongs to one of these $M$ types. Also, for each type of plush toy, there is at least $1$ plush toy present.
To make the display look nice, they want to rearrange the plush toys so that all plush toys of the same type are placed contiguously on the shelf. They decided to rearrange the plush toys in the following way:
- Choose some of the $N$ plush toys and remove them from the shelf. Do not move the positions of the plush toys that were not removed.
- Place the removed plush toys back into the empty compartments of the shelf in any desired order.
After rearranging, all plush toys of the same type must be placed contiguously on the shelf. Write a program to find the minimum number of plush toys to remove in order to rearrange them.
Input
The input consists of $1 + N$ lines.
On line $1$, $2$ integers $N, M$ ($1 \le N \le 100000$, $1 \le M \le 20$) are written separated by a space, indicating that there are $N$ plush toys and $M$ types of plush toys.
On each of the following $N$ lines, an integer between $1$ and $M$, inclusive, is written. The integer written on the $i$-th line ($1 \le i \le N$) among the $N$ lines represents the type of the plush toy placed in the $i$-th compartment from the left of the shelf. For each type, it is guaranteed that at least $1$ plush toy exists.
Output
Print in $1$ line the minimum number of plush toys to remove in order to rearrange them.
Sample Input and Output
Sample Input 1
7 2 1 2 2 2 1 2 1
Sample Output 1
2
Sample Input 2
12 4 1 3 2 4 2 1 2 3 1 1 3 4
Sample Output 2
7
In Sample Input 1, the types of the plush toys initially placed are $1, 2, 2, 2, 1, 2, 1$ in order from the left. To minimize the number of plush toys removed for rearranging, one can remove the $1$-st and $6$-th plush toys from the left, and place a plush toy of type $2$ in the $1$-st position from the left and a plush toy of type $1$ in the $6$-th position from the left. In this case, the number of plush toys removed is $2$.