#include<bits/stdc++.h>
using namespace std;
const int N=1010;
bool st[N];//记录当前元素是否在队列中
queue<int> q;
int main()
{
int m,n;
cin>>m>>n;
int res=0;
for(int i=0;i<n;i++)
{
int a;
cin>>a;
if(!st[a])//表示没有在内存中,才会需要去查字典
{
if(q.size()==m)
{
int t=q.front();//对头弹出
q.pop();
//q.push(a);这条是多余的,应为正确与否,a都会入队,如果执行会重复入队
st[t]=false;
}
q.push(a);
st[a]=true;
res++;
}
}
cout<<res<<endl;
return 0;
}