var
c:byte;
t:text;
i,a,p,n,k:integer;
begin
assign(t,'aparitiicifra.in');
reset(t);
read(t,n,c);
close(t);
if (n>=2000000000) or (n<=0) or (c>=10) or (c<=0) then exit;
a:=0;
for i:=1 to n do begin
k:=i;
while k<>0 do begin
p:=k mod 10;
k:=k div 10;
if p=c then inc(a);
end;
end;
assign(t,'aparitiicifra.out');
rewrite(t);
write(t,a);
close(t);
end.