按题意模拟即可。
#include <cstdio>
#include <cstring>
#include <queue>
#define N 1005
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x*f;
}
int n,m,ans=0;
bool f[N];
std::queue<int> q;
int main(){
// freopen("a.in","r",stdin);
m=read();n=read();
while(n--){
int x=read();
if(f[x]) continue;
ans++;f[x]=1;
if(q.size()<m) q.push(x);
else f[q.front()]=0,q.pop(),q.push(x);
}
printf("%d\n",ans);
return 0;
}