#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

int main() {
    int m, n, ans = 0;
    cin >> m >> n;
    queue<int> q;
    
  	// 操作队列同时,维护一个具有长度的缓存数组
  	// 通过读取数组index确定是否命中缓存
    bool inCache[1001] = {false};
    int cacheSize = 0;
    
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        if (!inCache[t]) {
            ans++;
            if (cacheSize < m) {
                q.push(t);
                inCache[t] = true;
                cacheSize++;
            } else {
                int removed = q.front();
                q.pop();
                inCache[removed] = false;
                q.push(t);
                inCache[t] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}