var p:integer;
    k,i:byte;
    tmp:longint;
function prchi(p:longint):longint;
var i,ot:longint;
begin
     ot:=0;
     for i:=2 to p-1 do
         if (p mod i)=0 then ot:=i;
     prchi:=ot;
end;
function proiz(p:longint):longint;
var a,b,ot:longint;
begin
     if p=1 then proiz:=0;
     a:=prchi(p);
     if a=0 then proiz:=1;
     if a>0 then
     begin
          b:=p div a;
          ot:=proiz(a)*(b)+proiz(b)*a;
          proiz:=ot
     end;
end;
begin
readln(p,k);
tmp:=proiz(p);
for i:=1 to k-1 do
    tmp:=proiz(tmp);

write(tmp);
end.