program alex;
var f:text;
    a:array[0..200001]of integer;
    d,n,sol,i:longint;
begin
assign(f,'obstacole.in');reset(f);
readln(f,n,d);
for i:=1 to n do
    read(f,a[i]);
close(f);
assign(f,'obstacole.out');rewrite(f);
sol:=999999999;
d:=0;
for i:=1 to n do
    if a[i]=0 then d:=d+1
    else if a[i]=1 then begin
                        if(d<sol)and(d>0)then sol:=d;
                        d:=0;
                        end;
writeln(f,sol);
close(f);
end.