var j,n,m,temp,ans,i,x,head,tail:longint;
queue:array[1..10000]of longint;
f:boolean;
begin
assign(input,'translate.in');reset(input);
assign(output,'translate.out');rewrite(output);
ans:=0;
read(n,m);
head:=1;
tail:=head+n-1;
temp:=head;
for i:=head to tail do queue[i]:=-1;
for i:=1 to m do
begin
f:=false;
read(x);
for j:=head to tail do
if queue[j]=x then f:=true;
if not f then
if temp<=tail then begin inc(ans);queue[temp]:=x;inc(temp);end
else if temp>tail then begin inc(temp);inc(ans);inc(head);inc(tail);queue[tail]:=x;end;
end;
write(ans);close(input);close(output);
end.