{$S-}
var p,i,k:longint;

function stupid(a:longint):boolean;
 var i:longint;
     st:boolean;
  begin
   st:=true;
   for i:=2 to a-1 do
    if a mod i=0 then
     begin
      st:=false;
      break;
     end;
   stupid:=st;
  end;

function pp(p:longint):longint;
 var a,b,i,a1,b1:longint;
  begin
   for i:=2 to p-1 do
    if p mod i=0 then
     begin
      a:=i;
      b:=p div i;
      break;
     end;
   if stupid(a) then a1:=1 else
   a1:=pp(a);
   if stupid(b) then b1:=1 else
   b1:=pp(b);
   pp:=a1*b+a*b1;
  end;

 begin
  readln(p,k);
  for i:=1 to k do
   begin
    if stupid(p)then begin writeln(0);exit;end;
    p:=pp(p);
   end;
   if k=0 then writeln(0) else writeln(p);
 end.






