You are given a row of m stones, each painted with one of k colors. You want to remove some stones so that no two stones of the same color are separated by a stone of a different color — in other words, when the remaining stones are read from left to right, all stones of each color form a single contiguous block. You may not reorder the stones; you may only remove them. Find the minimum number of stones you must remove.
The input consists of several test cases. The first line of each test case contains two integers m and k (1≤m≤100, 1≤k≤5). The next line contains m integers x1,…,xm, each from the set {1,…,k}, giving the color of every stone. The end of input is marked by a line with m=k=0, which must not be processed.
For each test case, print on its own line the minimum number of stones that must be removed to satisfy the condition.
For example, if the stone colors are 2 1 2 2 1 1 3 1 3 3, removing the 2nd and 7th stones leaves 2 2 2 1 1 1 3 3 — three 2s, three 1s, and two 3s, each grouped into a single block — so the minimum number of removals is 2. Other optimal solutions may exist.