program deriv;
var p,del:longint;
    k,j:byte;

function prosto(pom:longint):boolean;
var i:longint;
    bool:boolean;
begin
     i:=2; bool:=true; del:=1;
     while ((pom div 2)>=i) and (bool=true) do begin
           if (pom mod i)=0
              then begin
                   bool:=false;
                   del:=i;
              end;
           inc(i);
     end;
     prosto:=bool
end;

function o_pepi(pp:longint):longint;
var a,b,pp1,pp2:longint;
begin
     if pp=1
        then o_pepi:=0
        else if prosto(pp)
             then o_pepi:=1
             else begin
                  b:=del; a:=pp div b;
                  pp1:=(o_pepi(a)*b);
                  pp2:=a;
                  o_pepi:=pp1+pp2;
             end;
end;

begin
     readln(p,k);
     for j:=1 to k do p:=o_pepi(p);
     writeln(p);
end.