#include <bits/stdc++.h>
using namespace std;
queue<int> st;
queue<int> q;
int m, n, x, ans;
bool t[10005];
int main(){
cin >> m >> n;
for (int i = 1; i <= n; i++) {
cin >> x;
if (t[x]){
continue;
}
if (st.size()>=m) { //如果队列st的元素个数 >= m
t[st.front()] = 0;
st.pop();
}
st.push(x);
t[x] = 1;
ans++; //查词典的次数 + 1
}
cout << ans << endl;
return 0;
}