#P353. 【例61.1】 机器翻译

【例61.1】 机器翻译

Description

Xiaochen has a machine translation software installed on his computer, which he often uses to translate English articles.
The principle of this translation software is simple: it replaces each English word with its corresponding Chinese meaning from beginning to end. For each English word, the software first checks if the Chinese meaning is in memory. If it is, the software uses it for translation; if not, the software looks up the word in the dictionary on external storage, finds the Chinese meaning, translates it, and stores the word and its translation in memory for future lookups and translations.
Assume that memory has MM units, each capable of storing one word and its translation. Before the software stores a new word in memory, if the current number of words stored in memory does not exceed M1M-1, the software will store the new word in an unused memory unit; if memory already contains MM words, the software will clear the earliest word in memory to make room for the new word.
Assume that an English article has a length of NN words. Given this article to be translated, how many times does the translation software need to look up the dictionary in external storage? Assume that memory is empty before the translation begins.

Input Format

The input consists of 22 lines. Each line contains numbers separated by a single space.
The first line contains two positive integers MM and NN, representing the memory capacity and the length of the article.
The second line contains NN non-negative integers, representing English words in the order they appear in the article. Each number (not exceeding 10001000) represents an English word. Two words in the article are the same if and only if their corresponding non-negative integers are the same.

Output Format

A single line containing an integer, representing the number of times the software needs to look up the dictionary.

Sample

3 7
1 2 1 5 4 4 1
5