Farmer John's N cows (1 <= N <= 100,000) are lined up in a row.Each cow is labeled with a number in the range 1...K (1 <= K <=10,000) identifying her breed. For example, a line of 14 cows might have these breeds:
1 5 3 2 5 1 3 4 4 2 5 1 2 3
* Line 1: Two integers, N and K
* Lines 2..N+1: Each line contains a single integer that is the breed ID of a cow. Line 2 describes cow 1; line 3 describes cow 2; and so on.
* Line 1: The length of the shortest sequence that is not a subsequence of the input
14 5 1 5 3 2 5 1 3 4 4 2 5 1 2 3
3
All the single digit 'sequences' appear. Each of the 25 two digit sequences also appears. Of the three digit sequences, the sequence 2, 2, 4 does not appear.