水题,直接模拟即可

program translate;
var
  q:array[1..1000] of integer;
  a:array[1..1000] of boolean;
  ans,n,m,i,x,head,tail:integer;
begin
  assign(input,'translate.in');
  reset(input);
  assign(output,'translate.out');
  rewrite(output);
  fillchar(a,sizeof(a),false);
  readln(n,m);
  ans:=0;
  head:=1;
  tail:=0;
  for i:=1 to m do
  begin
    read(x);
    if a[x] then continue;
    if tail-head+1=n then
    begin
      a[q[head]]:=false;
      inc(head);
    end;
    if not a[x] then
    begin
      a[x]:=true;
      inc(ans);
      inc(tail);
      q[tail]:=x;
    end;
  end;
  readln;
  writeln(ans);
  close(input);
  close(output);
end.