#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char** argv) {
long long a,b,c,d,e,h,v;
cin>>a;
if(a<=1)return 0;
c=0;
p0: d=2;
p1: if(a%d!=0){
e=3;
h=sqrt(d);
v=sqrt(a);
p2: d++;
p3: if(e!=3&&d%e==0)goto p2;
e++;
if(e<=h&&d<=v) goto p3;
goto p1; }
b=a/d;
c=c+d;
if(b==1)goto p4;
a=b;
goto p0;
p4: cout<<c<<endl; }