Var k,n,d,m,s:integer;
begin
k := 1;
d := 2;
read(n);
while n > 1 do
begin
s := 0;
m := 1;
while n mod d = 0 do
begin
if m mod d <> 0 then
begin
s := s + d;
m := s;
end;
n := n div d;
m := m div d;
end;
if s > k then k := s;
d := d + 1
end;
writeln(k)
end.