var a,b,i,j,sum:longint; x:ansistring; b1:string; begin read(a,b); str(b,b1); for i:=1 to a do begin str(i,x); for j:=1 to length(x) do if x[j]=b1 then sum:=sum+1; end; write(sum); end.