{$s-}
const max = 1000000;
var prime : array[1..max] of boolean;
    {a:Array[1..100000] of Longint;}
    i,j,p,k:Longint;
    result,temp:QWord;
    found:Boolean;
procedure eratos;
var i,j : longint;
begin
  prime[1]:=false;
 for i:=2 to max do
  prime[i]:=true;
 for i:=2 to max div 2 do
  if prime[i] then
   for j:=2 to max div i do
    prime[i*j]:=false;
  j:=0;
 for i:=1 to max do
 begin
  if prime[i] then
   begin
     inc(j);
    if (j mod 10)=0 then
   end;
 end;
end;

Function born(x:Qword):Qword;
var delitel:QWord;
Begin
 If (x=1)or(x=0) then Begin
                        born:=0;
                        Exit;
                      End;
 {If Prime[x] then
 Begin
   born:=1;
   Exit;
 End;}
 {If a[x]<>0 then Begin
                   born:=a[x];
                   Exit;
                 End;}
 {If a[x]=0 then}
 Begin
   delitel:=1;
  Repeat
    delitel:=delitel+1;
   if (x mod delitel=0)and(x div delitel>=1) then break;
  Until delitel=x;
  If (delitel=x)or(delitel=1)then
  Begin
    born:=1;
    Exit;
  End;
   temp:=born(delitel)*(x div delitel)+delitel*born(x div delitel);
   {a[x]:=temp;}
   born:=temp;
   Exit;
 End;
End;

Begin
  eratos;
{ For i:=1 to max do
  if prime[i] then a[i]:=1;}
  ReadLn(p,k);
  result:=p;
 For i:=1 to k do
   Result:=born(result);
  WriteLn(Result);
  ReadLn;
End.
