Program March;
var N:1..2000;
    P:0..2001;
    br,i,k,j,br_cif:integer;
    A:set of 0..9;
begin
     readln(N,P);
     br:=0;
     A:=[];
     br_cif:=1;
     for i:=1 to 9 do
         A:=A+[i];
     for i:=1 to N do br_cif:=br_cif*10;
     {for i:=1 to N do}
     writeln(br_cif);
     for i:=123 to br_cif do
         for j:=1 to N do
         begin
              k:=0;
              repeat
                    if (br_cif mod 10 in A) then br_cif:=br_cif div 10
                    else k:=1;
              until (k=1) or (br_cif=0);
              if (k=1) or (br_cif=0) then br:=br+1;
         end;
     writeln(br);
     readln;
end.