The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b pebbles (a > 1). Note that the Beaver must use all the pebbles he has, i. e. n = a·b.   10 pebbles are arranged in two rows, each row has 5 pebbles  Once the Smart Beaver has arranged the pebbles, he takes back any of the resulting rows (that is, b pebbles) and discards all other pebbles. Then he arranges all his pebbles again (possibly choosing other values of a and b) and takes back one row, and so on. The game continues until at some point the Beaver ends up with exactly one pebble. The game process can be represented as a finite sequence of integers c1, ..., ck, where:   c1 = n  ci + 1 is the number of pebbles that the Beaver ends up with after the i-th move, that is, the number of pebbles in a row after some arrangement of ci pebbles (1 ≤ i < k). Note that ci > ci + 1.  ck = 1 The result of the game is the sum of numbers ci. You are given n. Find the maximum possible result of the game.

The single line of the input contains a single integer n — the initial number of pebbles the Smart Beaver has. The input limitations for getting 30 points are:    2 ≤ n ≤ 50  The input limitations for getting 100 points are:    2 ≤ n ≤ 109

Print a single number — the maximum possible result of the game.

NoteConsider the first example (c1 = 10). The possible options for the game development are:  Arrange the pebbles in 10 rows, one pebble per row. Then c2 = 1, and the game ends after the first move with the result of 11.  Arrange the pebbles in 5 rows, two pebbles per row. Then c2 = 2, and the game continues. During the second move we have two pebbles which can be arranged in a unique way (remember that you are not allowed to put all the pebbles in the same row!) — 2 rows, one pebble per row. c3 = 1, and the game ends with the result of 13.  Finally, arrange the pebbles in two rows, five pebbles per row. The same logic leads us to c2 = 5, c3 = 1, and the game ends with the result of 16 — the maximum possible result.

#include<stdio.h>
#include<math.h>
int prime(int n)
{
    int i;
    if(n==1)return 0;
    if(n==2)return 1;
    int m=sqrt(n);
    for(i=2; i<=m; i++)
        if(n%i==0)return 0;
    return 1;
}
int f(int n)
{
    int i;
    if(prime(n))return n;
    for(i=2; i<=n; i++)
        if(n%i==0)return i;
}
int main()
{
    int n;
    long long ans=1;
    scanf("%d",&n);
    while(n!=1)
    {
        ans+=n;
        n/=f(n);
    }
    printf("%lld\n",ans);
    return 0;
}

#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>

using namespace std;

long long n, res;
bool flag;

int main()
{
	cin >> n;

	while(n > 1)
	{
		flag = false;
		res += n;
		for(long long i = 2; i*i <= n; i++)
			if(n % i == 0)
			{
				n /= i;
				flag = true;
				break;
			}
		if(!flag)
			break;
	}
	res++;
	cout << res;

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int *pr;
    int npr;
    int i,j;
    int n;
    int f;
    double sum;
    int cur;
    scanf("%d", &n);
    pr = (int*)malloc(10000*sizeof(int));
    npr = 1;
    pr[0] = 2;

    for(i=3; i<=sqrt((double)n); i++)
    {
        f = 1;
        for(j=0; j<npr;j++)
        {
            if(i%pr[j]==0)
            {
                f = 0;
                break;
            }
        }
        if(f)
        {
            pr[npr] = i;
            npr++;
        }
    }
    sum = n;
    cur = n;
    while (cur != 1)
    {
        f = 0;
        for(i=0; i<npr; i++)
        {
            if(cur%pr[i] == 0)
            {
                cur = cur/pr[i];
                sum+=cur;
                f = 1;
                break;
            }

        }
        if(!f)
        {
            cur = 1;
            sum+= cur;
        }
    }

    printf("%.lf", sum);

}

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

bool isprime(long long k)
{
    bool ok=true;
    for (int j=2; j<=sqrt(k); j++)
    if (!(k%j)) ok=false;
    return ok;
}
int nd(long long k)
{
    bool ok=true;
    for (int j=2; j<=sqrt(k); j++)
    if (!(k%j)) return j;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    long long n,ans=0;
    cin>>n;
    while(1)
    {
        ans+=n;
        n/=nd(n);
        if (isprime(n))
        {
            ans+=n;
            ans+=1;
            cout<<ans;
            return 0;
        }
    }
}

#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <array>
#include <map>
#include <iterator>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <search.h>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <numeric>
#include <bitset>
#include <sstream>
#include <stdio.h>
#include <set>
using namespace std;

//*****************************************************************************************************************************************************************

char letters[27] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
char reversed_letters[27] = { 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a' };
char vowels[13] = { 'A', 'O', 'E', 'Y', 'U', 'I', 'a', 'o', 'y', 'e', 'u', 'i' };

//*****************************************************************************************************************************************************************

long long find_max_vector(vector<long long int> arr) {
    int ans = 0;
    for (int i = 0; i < arr.size(); i++) {
        if (arr[i] > ans) { ans = arr[i]; }
    }
    return ans;
}
long long int factorial(long long  n) {
    return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
}
int gcd(long long a, long long  b)
{
    if (a == 0) { return b; }
    return gcd(b % a, a);
}
int linear_count(int n, vector<int>arr) {
    int ans = 0;
    for (int i = 0; i < arr.size(); i++) { if (arr[i] == n) { ans++; } }
    return ans;
}
long long  find_min_vector(vector<long long int> arr) {
    bool move = true;
    int ans = 0;
    for (int i = 0; i < arr.size(); i++) {
        if (move) { ans = arr[i]; }
        else if (arr[i] < ans) { ans = arr[i]; }
    }
    return ans;
}
bool is_palindrome(string s) {
    string copys = s; reverse(copys.begin(), copys.end()); return copys == s;
}
bool exist(char arr[13], char s) {
    for (int i = 0; i < 12; i++) { if (arr[i] == s) { return true; } }
    return false;
}
bool linear_search_boolean_string(string str, char s) {
    for (int i = 0; i < str.size(); i++) {
        if (str[i] == s) { return true; }
    }
    return false;
}
int sum_vector(vector<int> arr) {
    int ans = 0;
    for (int i = 0; i < arr.size(); i++) {
        ans += arr[i];
    }
    return ans;
}
string lower(string str) {
    for (int i = 0; i < str.size(); i++) { str[i] = tolower(str[i]); } return str;
}
string upper(string str) {
    for (int i = 0; i < str.size(); i++) { str[i] = toupper(str[i]); } return str;
}
long long lcm(long long a, long long b) {
    if (a > b)
        return (a / gcd(a, b)) * b;
    else
        return (b / gcd(a, b)) * a;
}
int digit_to_int(char x) {
    int answer = (int)x - 48;
    return answer;
}
int string_to_int(string s) {
    return stoi(s);
}
bool binarySearchboolean(vector<long long int>arr, int l, int r, int x) {
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return true;
        if (arr[mid] > x)
            return binarySearchboolean(arr, l, mid - 1, x);
        return binarySearchboolean(arr, mid + 1, r, x);
    }return false;
}
vector<long long int> primes;
void sieve(){

    const long long int N = 1000000;
    long long int arr[N + 1] = { 0 };
    arr[0] = 1;
    for (long long int i = 2; i <= N; i++)
    {
        for (long long int j = i * i; j <= N; j += i)
        {
            arr[j - 1] = 1;
        }
    }
    for (long long int i = 1; i <= N; i++)
    {
        if (arr[i - 1] == 0)
        {
            primes.push_back(i);
        }
    }
}
long long int count_combinations(long long int n , long long k) {
    return factorial(n) / (factorial(k) * factorial(n - k));
}
long long int count_permutations(long long int n, long long k) {
    return factorial(n) /  factorial(n - k);
}
long long int count_combinations_with_replacement(long long int n, long long k) {
    return (n + factorial(k - 1)) / (factorial(k) * factorial(n - k));
}

//*****************************************************************************************************************************************************************
#define ll long long
#define cll const long long
#define ci const int
#define pl pair<ll,ll>
#define pi pair < int,int>
#define vi vector<int>
#define vl vector <ll>
#define vpi vector <pair < int , int > >
#define setl set<ll>
#define seti set<int>
#define setc set<char>
#define setstr set<string>
#define db double
#define usetc set<char>
#define usetstr set<string>
#define uset unordered_set <int>
#define usetl unordered_set <ll>
#define chr char

//*****************************************************************************************************************************************************************

int main() {
    pi p = { 0 , 0 };
    int  k, n, test, ans = 0, pointer = 1000000000,row = 0,col = 0;
    cll N = 0;
    usetl sett;
    setl ss;
    map < ll, ll > frq;
    vl  arr,cs,mod;
    bool move = true;
    string str, s1 = "", s2 = "";
    cin>>n;
    while (n>1)
    {
        for (int i = 2; i <= n; i++)
        {
            if (n % i == 0)
            {
                ans += n; n /= i; break;
            }
            else if (i == n)
            {
                ans += n; n = 1;
            }
        }

    }
    if (n == 1) { ans++; }
    cout << ans << endl;
    return  0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,x,sum,i,z;
	while(scanf("%I64d",&n)!=EOF)
	{
		x=n;
		sum=0;
		while(x>0)
		{
			for(z=0,i=2;i<=sqrt(x);i++)
			{
				if(x%i==0)
				{
					sum+=x/i;
					x=x/i;
					z=1;
					break;
				}
			}
			if(z==0)
			{
				sum+=1;
				break;
			}
			//cout<<x<<endl;
		}
		printf("%I64d\n",sum+n);
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int  sum=0;
int solve(int n)
{
   if(n==1) return 1;
   int i,j,k;
   for(i=2;i<=(int)sqrt(n);i++)
      if(n%i==0) break;

   if(i==(int)sqrt(n)+1) k=solve(1);
   else k=solve(n/i);

   return k+n;
}
int main()
{
   int n;
   cin>>n;
   cout<<solve(n);

}

#import<iostream>
using namespace std;long long i=2,n,s;main(){for(cin>>n,s=n;i*i<=n;)n%i?i++:(s+=n/i,n/=i);cout<<s+1;}

#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <complex>
#include <numeric>
#include <valarray>
#include <iostream>
#include <memory.h>
#include <algorithm>
using namespace std;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i(0),_n(n);i<_n;++i)
#define repi(i,a,b) for(int i(a),_b(b);i<_b;++i)
template<class T> int len(const T&c){return (int)c.size();}
typedef long long ll;
#define repe(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
typedef vector<int> vi;
typedef vector<string> vs;
#define mem(x,a) memset(x,a,sizeof(x))
template<class T> void cmin(T &a,T b){if(b<a) a=b;}
template<class T> void cmax(T &a,T b){if(b>a) a=b;}
typedef pair<int,int> pii;

vector<int> Primelist(int N){
		vector<int > arr(N+1,1);
		vector<int> ret;
		arr[0]=arr[1]=0;
		ret.push_back(2);
		for(int  i=3;i<N;i+=2)
			{
				if(arr[i]==1){
					ret.push_back(i);
					for(int  j=i+i;j<N;j+=i)arr[j]=0;
				}
			}
		return ret;
}

int main(){

	map<int,int> Mp;

	int n,ans=0;
	vector<pair<int,int> > v;

	cin>>n;

	vi p=Primelist(sqrt(n+1)+1);

	queue<pair<int,int> > st;

	bool b;
	b=1;
	rep(i,len(p)){
		if(n%p[i]==0){
			st.push(mp(n/p[i],n));
			b=0;
		}
	}

	if(b){ans=n+1;}

	while(len(st)){
		pii tem=st.front();st.pop();
		if(tem.first==1)cmax(ans,tem.second+1);
		else {
			b=1;
			rep(i,len(p)){
				if(tem.first%p[i]==0){
					if(Mp[tem.first/p[i]]<tem.second+tem.first){
						st.push(mp(tem.first/p[i],tem.second+tem.first));
						Mp[tem.first/p[i]]=tem.second+tem.first;
					}
					b=0;
				}
				if(p[i]>tem.first)break;
			}
			if(b)cmax(ans,tem.second+tem.first+1);
		}
	}
	cout<<ans;
}

#include <iostream>
using namespace std;
//#include <math.h>
//#include <stdio.h>
//#include <string.h>
//#include <stdlib.h>

/*int partition(int *a,int l,int r)
{
	int x=a[r],i=l-1,buf;
	for(int j=l;j<r;j++)
		if(a[j]<x)
		{
			i++;
			buf=a[i],a[i]=a[j],a[j]=buf;
		}
	buf=a[i+1],a[i+1]=a[r],a[r]=buf;
	return i+1;
}

void sort(int *a,int l,int r)
{
	if(l<r)
	{
		int q=partition(a,l,r);
		sort(a,l,q-1);
		sort(a,q+1,r);
	}
}*/

int nd(int n)
{
	int i=2;
	while(n%i)i++;
	return i;
}

int main()
{
	int n;
	unsigned long long int kol;

	cin>>n;
	kol=n;
	while(n!=1)
		n=n/nd(n),kol+=n;

	cout<<kol;
    return 0;
}

#include <cmath>
#include <iostream>
using namespace std;
int n;
int r;
int main()
{
	scanf("%d", &n);
	int c = n;
	r = c;
	while(c != 1)
	{
		int d = 2;
		int m = (int)sqrt((float)c) + 1;
		while(d <= m && c % d != 0)
			d++;
		if(c % d != 0)
			d = c;
		while(c % d == 0)
		{
			c /= d;
			r += c;
		}
	}
	printf("%d", r);
	return 0;
}

/*************************
Bismillahir Rahmanir Rahim
--------------------------
  ++++++++++++++++
  + Naimul Islam +
  ++++++++++++++++
--------------------------
**************************/

#include<bits/stdc++.h>
using namespace std;

typedef     unsigned long long    ull;
typedef     long long                   ll;

#define     CS( x )    cout << "Case " << x << ": ";
#define     PI    ( acos( -1 ) )
#define     sq( x )    ( ( x ) * 1LL * ( x ) )
#define     mod    ( 1000000007 )
#define     EPS    1e-9
#define     inf    ( 1 << 28 )
#define     eb    emplace_back
#define     mp    make_pair
#define     all( _n )    _n.begin(), _n.end()
#define     Clear( a, b )    memset( a, b, sizeof( a ) )
#define     sp    ' '
#define     endl    "\n"
#define     nl    cout << endl
#define     ret    return
#define     D( x )    cout << #x << " is " << x << endl;
#define     precision( n )    cout << fixed << setprecision( n );
#define     dbg    cout << "KHELA HOBE" << endl;
#define     doura    ios::sync_with_stdio( false ), cin.tie( 0 ), cout.tie( 0 );
//-------------------------------------------------------------|
#define     F    first
#define     S    second
#define     ctoi( x )    ( ( x ) - '0' )
#define     itoc( x )    ( ( x ) + '0' )
#define     yes()    cout << "YES\n", exit( 0 );
#define     no()    cout << "NO\n", exit( 0 );
#define     tests    int tc; cin >> tc; while( tc-- )
#define     DD    cout <<"--\n";
#define     OUT( x )    cout << x << sp;
#define     sz( x )    int( x.size() )
#define     gcd( a, b )    __gcd( a, b )
#define     lcm( a, b )    ( abs( ( a ) * ( b ) ) / gcd( a, b ) )
//--------------------------------------------------------------|
int rec(int n)
{
    const int sqrtN = sqrt(n);
    for(int i=2; i<=sqrtN; i++)
    {
        if(n%i)
            continue;
        return n/i + rec(n/i);
    }
    return 1;

}

int main()
{
    doura;
    int n;
    cin >> n;
    int ans = ( n + rec(n) );
    cout << ans << endl ;

    ret 0;
}

/**
░▄▀▄▀▀▀▀▄▀▄░░░░░░░░░
░█░░░░░░░░▀▄░░░░░░▄░
█░░▀░░▀░░░░░▀▄▄░░█░█
█░▄░█▀░▄░░░░░░░▀▀░░█
█░░▀▀▀▀░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
░█░░▄▄░░▄▄▄▄░░▄▄░░█░
░█░▄▀█░▄▀░░█░▄▀█░▄▀░
░░▀░░░▀░░░░░▀░░░▀░░░
*/
#include <bits/stdc++.h>
#define br  break
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define un   unsigned
#define do   double
#define cr   char
#define st   string
#define sc   scanf
#define pr   printf
#define mk   make_pair
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define N    1000256
#define M    1000000007
#define I    1000000000000000000
#define en                 printf( "\n" )
#define sqr( a )           ( ( a ) * ( a ) )
#define all( c )           ( c ).begin(), ( c ).end()
#define rev( c )           reverse( all( c ) )
#define srt( c )           sort( all( c ) )
#define mxx( x, y, z )     max( x, max( y, z ) )
#define mnn( x, y, z )     min( x, min( y, z ) )
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
#define pif( x, y )        sqrt( sqr( x ) + sqr( y ) )
#define dist( x, y, z, c ) sqrt( sqr( x - z ) + sqr( y - c ) )
#define speed              ios_base::sync_with_stdio( 0 ), cin.tie( 0 ), cout.tie( 0 )
#define toprun             ios_base::sync_with_stdio( 0 ), cin.tie( 0 )
using namespace std;
ll tests;
ll n, c, z, ans;
void solve()
{
    cin >> n;
    ans = n;
    while( n > 1 )
    {
        c = 1;
        for( int i = 2; i <= ( ll )sqrt( n ); i ++ )
        {
            if( n % i == 0 )
            {
                c = n / i;
                break;
            }
        }
        ans += c;
        n = c;
        //cout << n << " " << c << " " << ans << endl;
    }
    cout << ans;
}
int main()
{
    speed;
    /*cin >> tests;
    while( tests -- )*/
        solve();
}

/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>

using namespace std;

int smallestDivisor(int n)
{
    // if divisible by 2
    if (n % 2 == 0)
        return 2;

    // iterate from 3 to sqrt(n)
    for (int i = 3; i * i <= n; i += 2) {
        if (n % i == 0)
            return i;
    }

    return n;
}

int main()
{
    int n;
    cin >> n;
    int res = 0;
    while(1) {
        res += n;
        n/=smallestDivisor(n);

        if (n<=1) {
            break;
        }
    }

    res += 1;
    cout << res << endl;

    return 0;
}

using namespace std;
#include<bits/stdc++.h>
typedef long long int ll;
typedef double dl;
#define pb push_back
#define bg begin()
#define en end()
#define rbg rbegin()
#define ren rend()
#define sz size()
#define r0 return 0
#define F first
#define S second
ll printDivisors(long long n)
{
    vector<long long>v;
    long long e=0,o=0;
    for(long long i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if(n/i==i){
                v.push_back(i);
            }
            else {
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    sort(v.rbegin(),v.rend());
    return v[1];
}
main()
{
    ll n,x,y,t;
    cin>>n;
    x=n;
    while(1)
    {
       n=printDivisors(n);
       x=x+n;
       if(n==1)
            break;
    }
    cout<<x<<endl;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <cassert>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <utility>
#include <cmath>
#include <bitset>
#include <climits>
#include <iomanip>
#include <sstream>
using namespace std;

#define int long long

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef double T;
typedef vector<T> VT;
typedef vector<VT> VVT;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;

    int total = n;

    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            n /= i;
            total += n;
        }
    }

    if(n != 1)
        total++;

    cout << total << endl;

    return 0;
}

//
//  main.cpp
//  Contest
//
//  Created by 설 진석 on 12. 4. 21..
//  Copyright 2012년 연세대학교. All rights reserved.
//

#include <iostream>
#include <vector>
#define N 10000000

using namespace std;

int n, ret = 0;
vector<int> primes;
bool p[N];

int main (int argc, const char * argv[])
{
    cin >> n;
    for(int i = 2; i < N; i++) p[i] = true;
    for(int i = 2; i < N; i++)
    {
        if(p[i])
        {
            primes.push_back(i);
            for(int j = i + i; j < N; j += i)
            {
                p[j] = false;
            }
        }
    }
    ret += n;
    int k = n;
    int len = primes.size();
    while(k != 1)
    {
        if(k < 10000000 && p[k])
        {
            ret++;
            break;
        }
        int i = 0;
        while(i < len && k % primes[i] != 0) i++;
        if(i == len)
        {
            ret++;
            break;
        }
        k = k / primes[i];
        ret += k;
    }

    cout << ret << endl;
    return 0;
}

///ShzFahad
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
    ll n,i,sum=0;
    cin >> n;
    while(n!=1)
    {
        sum = sum + n;
        for(i=2;i<=n;i++)
        {
            if(n%i==0)
            {
                n=n/i;
                break;
            }
        }
    }
    cout << sum+1 << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cy cout<<"YES"<<endl
#define cn cout<<"NO"<<endl
#define ms(a,b) memset(a, b, sizeof a);
#define scd(n) scanf("%d",&n)
#define scld(n) scanf("%lld",&n)
#define lp(i,a,b) for(i=a; i<b; i++)

int main()
{
    int t; t=1;
    while(t--)
    {
        ll n; cin>>n;
        ll ans=n;
        while(n>1)
        {
            for(int i=2; i<=n; i++)
            {
                if(n%i==0)
                {
                    n/=i;
                    ans+=n;
                    break;
                }
            }
        }
        cout<<ans;
    }
    return 0;
}

#include <bits/stdc++.h>
#define int long long int
#define loop(i,a,b) for(int i=a;i<b;i++)
#define revloop(i,a,b) for(int i=a;i>b;i--)
#define INF 10000009
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define chk(a,b) cout<<a<<" "<<b<<nl;
#define sop(a) cout<<a<<" "<<nl;
#define sz(x) (int)x.size()//int value is this
#define nl "\n"
#define pb(x) push_back(x)
using namespace std;

/*Memento Mori*/
//15July

int gcd(int x){
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0){ return i;}
	}
	return 1;
}
//Beaver
signed main(){
	fastio; int n;
	cin>>n;
	int ans=1; int q;
	while(n>1&&q!=1){
		ans+=n;
		q=gcd(n);
		//cout<<q<<"for"<<n<<nl;

		n=n/q;
	}cout<<ans<<nl;

}

#include <iostream>
using namespace std;
int main(){
    int n,bardar;
    bool check;
    cin>>n;
    int sum=n;
    while(n>1){
        check=0;
        for(int i=2;i*i<n+1;i++){
            if(n%i==0){
                n=n/i;
                check=1;
                break;
            }
        }
        if(check){
            //cout<<n<<" "<<sum<<endl;
            sum+=n;
        }
        else
            break;
    }
    sum++;
    cout<<sum<<endl;
}

#include <bits/stdc++.h>

using namespace std;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define forr(a,b,c) for(int (a)=(b); (a)<(c); (a++))
#define form(a,b,c) for(int (a)=(b); (a)>(c); (a--))
#define fori(a,b) for(auto (a):(b))
#define pb(a) push_back(a)
#define INF ((unsigned) ~0)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}
/* GCD of vector:   int r=vec[0];
                    for(int i=1; i<vec.size(); i++)
                    {
                        r=gcd(vec[i],r);
                    }
*/

int main()
{
    fastIO
    vector<bool> prime(100000,true);
    for(ll i=2; i*i<=100000; i++)
    {
        if(prime[i])
        {
            for(ll j=i*i; j<=100000; j+=i)
            {
                prime[j]=false;
            }
        }
    }
    ll n;
    cin>>n;
    vi primes;
    forr(i,2,100000)
    {
        if(prime[i]) primes.pb(i);
    }
    int siz=primes.size();
    ll ans=n,d;
    while(n!=1)
    {
        bool np=true;
        forr(i,0,siz)
        {
            if(n%primes[i]==0) {ans+=n/primes[i]; n/=primes[i]; np=false; break;}
        }
        if(np) {ans++; break;}
    }
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define se second
#define fr first
#define pb push_back
#define TIME ios_base::sync_with_stdio(0)
using namespace std;
ll n, m, ans;
ll pr( ll v )
{
    for( ll i = 2; i *i <= v; i ++ )
    {
        if( v % i == 0 )
        {
            return false;
        }
    }
    return true;
}
int main()
{
    TIME;
    cin >> n;
    if( pr(n) )
    {
        cout << n + 1 << endl;
        return 0;
    }
    while( n > 1 )
    {
        //cout << 1 << endl;
        if( n % 2 == 0 )
        {
            ans += n;
            n /= 2;
        }
        else if( n % 3 == 0 )
        {
            ans += n;
            n /= 3;
        }

        else if( n % 5 == 0 )
        {
            ans += n;
            n /= 5;
        }
        else if( n % 7 == 0 )
        {
            ans += n;
            n /= 7;
        }
        else if( !pr(n) )
        {
            for( ll i = 2; i <= sqrt(n); i ++ )
            {
                if( n % i == 0 )
                {
                    ans += n;
                    n/= i;
                    break;
                }
            }
        }
        else
        {
            ans += n;
            n /= n;
        }
    }
    cout << ans +1 << endl;
}

#include <bits/stdc++.h>
using namespace std;
long long n,sum;
int flag;
int main(){
	cin>>n;
	sum = n;
	while(n>1){
		flag = 1;
		for(int i = 2;i <= sqrt(n);i++){
			if(n%i==0){
				n /= i;
				sum += n;
				flag = 0;
				break;
			}
		}
		if(flag) {
			cout<<sum+1<<endl;
			return 0;
		}
	}
	cout<<sum<<endl;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    long long int n, res;
    cin>>n;
    res=n;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
                res+=n;
            }
        }
    }
    if(n!=1)
        res++;
    cout<<res<<endl;
    return 0;
}

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int k = n;
	int ans = 1;
	while (k > 1)
	{
		int l = 0;
		bool b = false;
		for (int j = 2; j <= sqrt((double)k); j++)
			if (k % j == 0)
			{
				b = true;
				l = j;
				break;
			}
		if (!b)
			l = k;
		ans += k;
		k = k / l;
	}
	cout << ans << endl;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
const int MAX=(int)1e7+10;
bool ispr[MAX];
int pr[MAX],pn,n;
void init()
{
	memset(ispr,true,sizeof(ispr));
	for (int k=2; k<MAX; k++) {
		if (ispr[k]) pr[pn++]=k;
		for (int i=0; i<pn && k*pr[i]<MAX; i++) {
			ispr[k*pr[i]]=false;
			if (k%pr[i]==0) break;
			//cos for m=k*pr[j](j>i),k%pr[i]==0,
			//thus, pr[i]|m, so there is no need
			//to continue the siezing process
		}
	}
}

int main()
{
	init();
	scanf("%d",&n);
	long long ans=n;
	int i=0;
	while (n>1&&i<pn) {
		while (n%pr[i]==0) {
			ans+=n/pr[i];
			n/=pr[i];
		}
		i++;
	}
	if (i>=pn) {
		for (int k=pr[pn-1]; k*k<=n; k++) {
			while (n%k==0) {
				ans+=n/k;
				n/=k;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

bool prost(long long n)
{
	if(n == 1)
		return 0;

	for(long long i = 2; i <= sqrt(n); i++)
	{
		if(n % i == 0)
			return 0;
	}

	return 1;
}

int main()
{
	long long n;
	cin >> n;

	long long i = 1;
	long long s = n;

	if(prost(n))
	{
		cout << n + 1;
		return 0;
	}

	while(n > 1)
	{
		i++;
		if(n % i != 0)
			continue;

		while(n % i == 0)
		{
			n /= i;
			s += n;
		}

		if(prost(n))
		{
			s++;
			break;
		}
	}

	cout << s;

	return 0;
}

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = "; cout << (x) << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
using namespace std;

map<int, ll> f;
ll get(int n) {
    if (f.count(n)) return f[n];

    ll res = 1;
    for(int i = 2; i*i <= n; ++i)
        if (n % i == 0) {
            res = max(res, get(i));
            res = max(res, get(n/i));
        }
    return f[n] = res + n;
}

int main() {
    int n;
    while (cin >> n) {
        f.clear();
        cout << get(n) << endl;
    }
    return 0;
}

#include<iostream>
using namespace std;
long long n,s,t;
bool b;
int main(){
    cin>>n;
	s=n+1;
	while(n>1&&b==0){b=1;
		for(t=2;t*t<=n&&b==1;t++)
			if(n%t==0){
				n=n/t;
				s=s+n;
				b=0;}
    }
	cout<<s;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,ans,minn;
int main(){
    scanf("%d",&n);
    while(n>1){
        minn=n;
        for(int i=2;i<=sqrt(n);i++){
            if(n%i==0){
                minn=i;
                break;
            }
        }
        ans+=n;
        n/=minn;
    }
    printf("%d",ans+1);
}

#include<bits/stdc++.h>
using namespace std;

#define MOD 1000000007
const int MAX = 1e6 + 7;
const int INF = 1e9;
int n, m, k, p, q, a, b, c, d, x, cnt = 0, ans = 0;

int MAIN()
{
        cin >> n;
        while(n > 1)
        {
                ans += n;
                bool isPrime = true;
                for(int i = 2; i * i <= n; ++i)
                        if(n % i == 0)
                        {
                                n = n / i;
                                isPrime = false;
                                break;
                        }
                if(isPrime)
                        break;
        }
        cout << ans + 1;
        return 0;
}

int main()
{
        ios_base::sync_with_stdio(false);
        int start = clock();
        #ifndef ONLINE_JUDGE
                freopen("in.txt", "rt", stdin);
                //freopen("out.txt", "wt", stdout);
        #endif
        cout << fixed << setprecision(16);
        int ret = MAIN();
        #ifndef ONLINE_JUDGE
            cout << "[Finished in " << clock() - start << " ms]" << endl;
        #endif
        return ret;
}

#include<bits/stdc++.h>
using namespace std;

bool prime(int n){
	for (int i=2;i<n;i++){
		if (n%i==0)
			return false;
	}
	return true;
}

int answer(int n){
	if (prime(n)){
		return n+1;
	}

	vector<int> v;
	for (int i=1;i<n;i++){
		if (n%i==0)
			v.push_back(i);
	}
	return n + answer(v[v.size()-1]);

}

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int ans;

	ans = answer(n);

	cout<<ans<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define MOD 1000000007
const int MAX = 1e6 + 7;
const int INF = 1e9;
int n, m, k, p, q, a, b, c, d, x, cnt = 0, ans = 0;

//from marat.snowbear
//for test 4 - 36
//36 + 18 + 9 + 3 + 1 = 67, between 1 and 36, we find the other highest divisors of the previous number by
//dividing it by the lowest factor, and after dividing we don't need to find the divisor smaller than the
//current one, because if it would exist, it would divide the previous number first.
//do some paper work

int MAIN()
{
        cin >> n;
        ans = n;
        for (int i = 2; i * i <= n ; i++)
                if (n % i == 0)
                {
                        n = n / i;
                        ans += n;
                        i--;
                }
        cout << ans + 1;
        return 0;
}

int main()
{
        ios_base::sync_with_stdio(false);
        int start = clock();
        #ifndef ONLINE_JUDGE
                freopen("in.txt", "rt", stdin);
                //freopen("out.txt", "wt", stdout);
        #endif
        cout << fixed << setprecision(16);
        int ret = MAIN();
        #ifndef ONLINE_JUDGE
            cout << "[Finished in " << clock() - start << " ms]" << endl;
        #endif
        return ret;
}

// http://codeforces.com/problemset/problem/177/B1

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>

using namespace std ;

int main()
{
    int n  , t = 0 ;
    scanf("%d",&n);
    t+=n ;
    while(n > 1)
        for(int j = 2 ; j <= n ; ++j)
            if(n%j==0)
            {
                t+=n/j ;
                n/=j ;
                break ;
            }
    printf("%d\n",t);
}

#include<bits/stdc++.h>
using namespace std;

main(){
    int n;
    scanf("%d" , &n);

    long long ans = 0;
    while( true ){
        ans += n;
        bool ok = 0;
        for(int i = 2 ; i*i <= n ; i ++){
            if(n%i == 0){
                ok = 1;
                n = n/i;
                break;
            }
        }

        if(!ok)break;
    }
    cout << ans + 1;
}

#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable:4786)

#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <ctime>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cctype>
#include <string>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <numeric>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define MAX_SIZE 100100
#define MAX_LENGTH 100100
#define INF ( 1 << 29 );

#define CLR( a ) memset( a , NULL , sizeof( a ) )
#define MEM( a ) memset( a , -1 , sizeof( a ) )
#define fort( a , b ) for( ind = ( a ); ind <= ( b ); ind++ )
#define foriab( a , b ) for( i = ( a ); i < ( b ); i++ )
#define fori( a ) for( i = 0; i < ( a ); i++ )
#define forj( a ) for( j = 0; j < ( a ); j++ )
#define print1( a ) printf( "%lld ---\n" , ( a ) )
#define print2( a , b ) printf( "%d %d ---\n" , ( a ) , ( b ) )

typedef __int64 lll ;

int MIN( int a , int b ) { return a < b ? a : b ; }
int MAX( int a , int b ) { return a > b ? a : b ; }
int GCD( int a , int b ) { while( b ) b ^= a ^= b ^= a %= b ; return a ; }
int LCM( int a , int b ) { return a * ( b / GCD( a , b ) ) ; }
void SWAP( int &a , int &b ) { a = a ^ b ; b = a ^ b ; a = a ^ b ; }

const double PI = acos( -1 ) ;
const double EPS = 1e-11 ;

int main() {
    //freopen( "B.in" , "r" , stdin ) ;
	//freopen( "out.txt" , "w" , stdout ) ;
	lll T , res , n , i , ind ;
	while( scanf( "%I64d" , &n ) != EOF ) {
        res = n ;
        while( 1 ) {
            lll sq = ( sqrt( n ) + EPS ) ;
            bool fl = 0 ;
            for( i = 2 ; i <= sq ; i++ ) {
                if( n % i == 0 ) {
                    res += ( n / i ) ;
                    fl = 1 ;
                    break ;
                }
            }
            n = n / i ;
            if( n == 1 || fl == 0 ) {
                res++ ;
                break ;
            }
        }
		printf( "%I64d\n" , res ) ;
	}
	return 0 ;
}

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;

#define pb push_back
#define rs resize
#define X first
#define Y second

using namespace std;

void read(){
    freopen("pudge.in", "r", stdin);
    freopen("pudge.out", "w", stdout);
}

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main(){

    //read();

    faster();

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 2; i * i <= n; i++){
        while(n % i == 0){
            ans += n;
            n /= i;
        }
    }
    if (n != 1)
        ans += n;
    cout << ans + 1;

    return 0;
}

#include <cstdio>
#include <cmath>

int g(int n) {
  int a = sqrt((double)n);
  for (int i = 2; i <= a; ++i)
    if (n % i == 0)  return n / i;
  return 1;

}

int main() {
  int n;
  scanf("%d", &n);
  int sum = n;
  while (n > 1) {
    n = g(n);
    sum += n;
  }
  printf("%d\n", sum);
  return 0;
}

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <sstream>

using namespace std;

int main()
{
	int n; cin >> n;long long ans = n;
	for (int i = 2; i * i <= n; ++i)
	{
		while (n % i == 0)
		{
			n /= i;
			ans += n;
		}
	}
	if (n > 1) ans++;
	cout << ans << endl;
	return 0;
}

#pragma comment(linker, "/STACK:500000000")
#include <iostream>
#include <math.h>
#include <string>
#include <conio.h>
#include <stdio.h>
using namespace std;
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}

bool Search(char *str)
{
	for(char *c = str; *c; c++)
		if (*c != ' ')
			return *c == '#';

	return false;
}
int main()
{
	long long n ;
	long long ans=0;
	cin >> n ;
	ans=n;
	while (n>1)
	{
		if (n%2==0)
		{
			ans+=n/2;
			n/=2;
		}
		else
		{
			bool flag = false;
			for (int i = 2 ; i <= sqrt((double)n)+1 ; i ++ )
			{
				if (n%i==0 )
				{
					ans+= n/i;
					n/=i;
					flag =true;
					break;
				}
			}
			if (flag == false )
			{
				ans+=n/n;
				n/=n;
			}
		}
	}

	cout << ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,c;
    cin>>n;
    c=n;
    for(int i=2;i<=n-1;i++)
      {
         if(n%i==0)
           {
               n/=i;
               c+=n;
               i=1;
           }
      }
      cout<<++c;
return 0;
}

#if __has_include("debug.h")
    #include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif

    fast

    int t = 1;
	// cin>>t;

	while(t--)
	    solve();
	return 0;
}

void solve()
{
	int i,j;
	int n;
	cin>>n;

	int sum=n;

	while(n>1)
	{
		d(n);
		bool flag=0;
		for(int i=2;i<=sqrt(n);i++)
		{
			if(n%i==0)
			{
				sum+=(n/i);
				n/=i;
				flag=1;
				break;
			}

		}
		if(!flag)
		{
			sum++;
			break;
		}
	}
	cout<<sum<<endl;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<ll, ll> isprime(ll n){
    pair<ll, ll> p;
    p.first = 0;
    p.second = 0;
    for(ll i = 2; i*i <= n; i++){
        if(i*i == n){
            p.first = i;
            p.second = i;
            return p;
        }
        if(n%i == 0){
            p.first = n/i;
            p.second = i;
            return p;
        }
    }
    return p;
}
int main(){
    ll n; cin >> n;
    ll sum = 0;

    while(1){
        pair<ll, ll> p = isprime(n);
//        cout << n << endl;
        if(!p.first){
            sum += n+1;
            break;
        }
        sum += n;
        n = p.first;

    }

    cout << sum << endl;

}

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;
#define pb push_back
#define mp make_pair
#define sc scanf
#define pii pair<int, int>
#define psi pair<string, i>
map<long long, long long> dp;
bool p[100000];

long long mmax(long long a, long long b){
 	if(a > b) return a;
 	return b;
}

long long calc(long long n){
 	if(n == 1)  return 1;
 	if(n < 100000 && !p[n]) return n + 1;
 	if(dp.find(n) != dp.end())  return dp.find(n)->second;
 	long long res = n;
 	bool ok = false;
 	for(int i = 2; i * i <= n; ++i)
 		if(n % i == 0){
 		 	res = mmax(res, n + calc(i));
 		 	res = mmax(res, n + calc(n / i));
 		 	ok = true;
 		}
 	if(!ok) res = n + 1;
 	dp.insert(mp(n, res));
 	return res;
}

int main() {
	cin.ios_base::sync_with_stdio();
	cout.ios_base::sync_with_stdio();
	long long n;
	cin >> n;
	for(int i = 2; i * i <= n; ++i)
		if(!p[i])
		for(int j = i + i; j < 100000; j += i)
			p[j] = true;

	cout << calc(n);
	return 0;
}

#include <iostream>
#include <math.h>
using namespace std;

int findGD(int n)
{
    int i = sqrt(n);
    if (n % 2 == 0) {
        return 2;
    }
    while (n % i != 0) {
        i--;
    }
    return i;
}
int main()
{
    int n;
    int score;
    cin >> n;
    score = n;
    int gd;
    while ((gd = findGD(n)) != 1) {
        n = n/gd;
        if (n == 1) {
            break;
        }
        score += n;
    }
    cout << score + 1;

}

#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;
ll findfactor(ll n){

   for(ll i=n/2;i>=2;i--){
      if(n%i==0)
         return i;
   }
   return n;
}
int main(){

   // #ifndef ONLINE_JUDGE
   //    FILE_READ_IN
   //    FILE_READ_OUT
   // #endif
   ll n; cin>>n;
   ll sum=n;
   while(n>1){
     ll fact= findfactor(n);

     if(n==fact) n=1;
     else n=fact;
     sum+=n;
   }
   cout<<sum<<"\n";
   return 0;
}

#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;

bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second>b.second);
}

void solve()
{

 int n,m;
 cin>>n;

 ll cnt=n;
 while(n>1)
 {
    int flag=0;
    if(n&1)
    {

        for(int i=3;i*i<=n;i+=2)
        {
            if(n%i==0)
            {

                n/=i;
                cnt+=n;
                flag=1;
                break;
            }
        }
        if(!flag)
        {
            cnt++;
            break;
        }

    }

    else
    {
        n/=2;
       cnt+=n;

    }
//cout<<cnt<<endl;
 }
 cout<<cnt<<endl;
}

 main()
{
    /*int t;
    cin>>t;

   while(t--)*/

    solve();

}

#include <bits/stdc++.h>

using namespace std;

long long solve(int n) {
  long long ans = n;
  for (int i = 2; i * i <= n; i++) {
    while (n != i && n % i == 0) {
      ans += n / i;
      n /= i;
    }
  }
  return ans + 1;
}

int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    long long ans = solve(n);
    printf("%lld\n", ans);
  }
  return 0;
}

///██╗ ██████╗ ██╗    ██████╗  ██████╗  ██████╗   ██████╗
///██║██╔═══██╗██║    ╚════██╗██╔═████╗ ╚════██╗ ██╔═████╗
///██║██║   ██║██║     █████╔╝██║██╔██║  █████╔╝ ██║██╔██║
///██║██║   ██║██║    ██╔═══╝ ████╔╝██║ ██╔═══╝  ████╔╝██║
///██║╚██████╔╝██║    ███████╗╚██████╔╝ ███████╗ ╚██████╔╝
///╚═╝ ╚═════╝ ╚═╝    ╚══════╝ ╚═════╝  ╚══════╝  ╚═════╝

#include<bits/stdc++.h>
#include<fstream>
///#include "windows.h"
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define mlojins cout.tie(NULL);
#define bzbz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front
#define Qulukh
#define quluq return 0;
#define Zohiri_dzd
#define Mekh
#define Black_star
using namespace std ;

const ll N = 1e6 + 1;

map <ll , ll> mp , pm ;
map <char , ll> hs ;
deque <ll> v , vc , ve ,vv , vd ;
deque <char> p , pe ;
deque <string> ts , ss , st , rs ;
deque <double> sd , ds ;
ll a , b , c , d , e , f , cnt , ans , r , n , l , x , y , mx;
ld q , t , cnt1 , cnt2 ;
string g , h , w , o , m , s ;
char z , u ;
bool re , rt ;
vector<pair < char , ll > > pr , rp , pp ;
map < pair < ll , ll > , ll > aw , wa ;
void cout_ (deque < ll > ree)
{
    for (ll i = 0 ; i < ree.size() ; i ++ )
        cout << ree[i] << " " ;
    cout << endl ;
    return ;
}
int main ()
{
    bzbz
    mlojins
    Mekh
    CODER
    Zohiri_dzd
    Black_star
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Author of the greatest code :: Murtazoev Alijon
    cin >> a ;
    b = a ;
    ans = a ;
    while (1)
    {
        n = 0 ;
        for (ll i = 2 ; i < b ; i ++ )
        {
            if (b % i == 0)
            {
                cnt = b / i ;
                n = 1 ;
                break ;
            }
        }
        if (n == 1)
        {
            ans += cnt ;
            b = cnt ;
        }
        else
        {
            cout << ans + 1 << endl ;
            return 0;
        }
    }
}
///Mavl studios
///Eco students
///8 is the best

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n; const int x=n;
    vector<int> v; int sum=0;
    while(n%2==0 && n/2!=1) {
        n=n/2;
        v.push_back(n);}
    for(int i=3;i<=sqrt(n);i+=2) {
        while(n%i==0 && n/i!=1) {
            n=n/i;
            v.push_back(n);}
    }

    for(int i=0;i<v.size();i++)
    sum+=v[i];
    cout<<x+1+sum;

}

#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iostream>
#include <fstream>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <sstream>
#include <stdio.h>
#include <stack>

using namespace std;

#define FOR(i,n) for (int i=0; i<n; ++i)
#define FORE(i,n) for (int i=0; i<=n; ++i)
#define REP(i,a,b) for (int i=a; i<b; ++i)
#define REPE(i,a,b) for (int i=a; i<=b; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define mp make_pair
#define INF (1e9)

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long int LL;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef pair<LL,LL> PLL;
typedef vector<VI> VVI;
const double pi = acos(-1.0);
const int inf =(int) 1e9;
map<int ,int > results;
set<int> used;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
#endif
	int n;
	cin>>n;
	int root = sqrt(n+ 0.0);
	map<int,int> dividers;
	REP(i,1,root+1)
	{
		if(n%i == 0)
		{
			dividers.insert(make_pair(n/i,n/i));
			dividers.insert(make_pair(i,i));
		}
	}
	dividers[1] = 1;
	for(map<int,int>:: iterator it = dividers.begin(); it!=dividers.end(); it++)
	{
		int x = sqrt((*it).first + 0.0);
		int target = (*it).first;

		for(int i = 1; i<= x; i++)
		{

			if(target % i == 0)
			{
				if(target == 1 && i==1) continue;
				if(i == 1)
					dividers[target] = max(dividers[i] + target,dividers[target]);
				else
					dividers[target] = max(max(dividers[i] + target,dividers[target]),
										max(dividers[target/i] + target,dividers[target]));
			}
		}
	}
	cout<<dividers[n];
	return 0;
}

#include<bits/stdc++.h>
#define  ll long long
using namespace std;
const int N= (int)5e6+20;
const ll inf = (int)1e18;
ll n, ans,m;
ll solve(ll x){
    if(x == 1){
        return 1;
    }
    for(ll i = 2; i *i <= x; ++i){
        if(x % i == 0){
            return solve(x/i) + x;
        }
    }
    return x+1;
}
int main(){
    cin >> n;
    cout<<  solve(n);

}

#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
	int n ; cin  >> n ;
	int x = n ;
	for(int i = 2 ; i*i <= n ; i++){
		 if(n%i==0){
		 	while(n%i==0){
		 		n/=i;
		 		x+=n;
			 }
		 }
	}
	if( n > 1) x+=1;
	cout << x << endl;
}

#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

int main() {
  int n; cin >> n;
  int64 sum = 0;
  for (;n>1;){
    sum += n;
    bool d = false;
    for (int i = 2; i*i <= n; i++) if (!(n%i)) {
      d=true;
      n/=i;
      break;
    }
    if (d) continue;
    if (!d) {
      n=1;
    }
  }
  sum += 1;
  cout << sum << endl;
  return 0;
}

#include <iostream>
#include <unordered_map>

using namespace std;

unordered_map<int, int> memo;
int dp(int n) {
    if (n == 1) return 1;
    if (n == 2) return 3;
    if (n == 3) return 4;
    if (memo.count(n)) return memo[n];
    int best = 0;
    for (int i = 2; i*i <= n; i++) {
        if (n%i == 0) best = max(max(best, dp(n/i)), dp(i));
    }
    if (best == 0) best += n+1;
    else best += n;
    memo[n] = best;
    return best;
}

int main() {
    int n; cin>>n;
    cout << dp(n) << endl;
}

#include <iostream>

#define ll long long
using namespace std;

int main()
{
	ll n, i, res{ 0 };
	cin >> n;

	res += n;
	while (n != 1)
	{
		for (i = 2; n % i != 0; i++);
		n = n / i;
		res += n;
	}

	cout << res;
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

long long n; cin >> n;
long long k = n;

for(int i = 2; i * i <= n; i++){
  if(n % i == 0){
    k += n / i;
    n = n / i;
    i = 1;
  }
}

cout << k + 1;

	return 0;
}

#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	while (true)
	{
		sum += n;
		if (n == 1)
		{
			cout << sum;
			return 0;
		}
		int i;
		for (i = 2 ; i <= int(sqrt(n + 0.0)) ; i ++)
			if (n % i == 0)
				break;
		if (n % i == 0)
			n /= i;
		else
			n = 1;
	}
	return 0;
}

#include <cstdio>

using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	int c=n;
	for(int i=2;i*i<=n;i++)
		while(n%i==0)
		{
			c+=n/i;
			n/=i;
		}
	if(n>1) c++;
	printf("%d",c);
	return 0;
}

//code by parshuram_84
#include <bits/stdc++.h>
#define mod 1000000007
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
#define mp make_pair
typedef std::numeric_limits< double > dbl;
using namespace std;

ll power(ll a,ll b)
{
	ll z=1,p=mod;
	while(b>0)
	{
		if(b&1) z=(z*a)%p;
		a=(a*a)%p;
		b=b>>1;
	}
	return z;
}

int main() {
	IOS;
	ll n,i,j,x,y,z=0,p=0,q;
	cin>>n;
	z+=n+1;
	while(n>1)
	{
		x=1;p=0;
		for(i=sqrt(n);i>1;i--)
		{
			if(n%i==0)
			{
				x=i;y=n/x;
				q=max(x,y);
				p=max(p,q);
			}
		}
		if(x==1) break;
		else
		{
			n=p;
			z+=n;
		}
	}
	cout<<z;
	return 0;
}

/**
 * @Khushit Shah
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL)

ll getBiggestDivisior(ll n) {
	ll sqr = sqrt(n);
	for(int i = 2; i <= sqr; i ++) {
		if(n % i == 0) return n / i;
	}
	return 1;
}

int main() {
	FASTIO;
	ll pebbles;
	cin  >> pebbles;

	ll ans = 0;
	while(pebbles != 1) {
		ans += pebbles;
		pebbles = getBiggestDivisior(pebbles);
	}
	cout << ans + 1;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
	long long a;
  cin >> a;
  queue<int> osztok;
  long long mo = a;
  for (int i = 2; i * i <= a; i++){
    if(a % i == 0){
      //osztok.push(i);

      a = a / i;
      mo += a;
      i--;
    }
  }
  cout << mo + 1;
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
     long long n,c=0;

     cin >> n;
	 c=n;

	while (n>1)
     {
               bool flagok = false;
               for (int i = 2 ; i <= sqrt((double)n)+1 ; i ++ )
               {
                    if (n%i==0 )
                    {
                         c+= n/i;
                         n/=i;
                         flagok =true;
                         break;
                    }
               }
               if (flagok == false )
               {
                    c+=n/n;
                    n/=n;
               }
          }

		//if (j==2) {c+=3;break;}

		 cout << c;

     return 0;
}

#include<bits/stdc++.h>
using namespace std;
inline long long read()
{
	long long kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
int su[1000000],c=0;bool vis[1000000];
int main()
{
	int n=read();
	for(int i=2;i<=n;++i)
	{
		if(!vis[i])su[++c]=i;
		for(int j=1;j<=c&&i*su[j]<=n;++j)
		{
			vis[i*su[j]]=1;
			if(i%su[j]==0)break;
		}
	}
	long long asd=n;
	while(n)
	{
		for(int i=1;i<=c;++i)
		{
			if(n%su[i]==0)
			{
				asd+=(n/su[i]);n=n/su[i];break;
			}
			if(n==1)
			{
				cout<<asd;
				return 0;
			}
		}
	}
	cout<<asd;
}

#include<bits/stdc++.h>
using namespace std;

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
}
typedef void (*callback_function)(void); // type for conciseness
const long long INF64 = 1e18;
const int INF32 = 1e9;

const int MAX_N = 1000 * 1000 * 2;

bool notPrime[MAX_N];

vec<int> primes;

void sieve() {
  notPrime[0] = notPrime[1] = true;
  FOR(i, 2, MAX_N) {
    if (!notPrime[i]) {
      primes.push_back(i);
      for (int j = i + i; j < MAX_N; j += i) notPrime[j] = true;
    }
  }
}

#undef int
int main() {
#define int long long
	ios_base::sync_with_stdio(false);
	cin.tie();
  //auto beginProgram = chrono::steady_clock::now();

  {// Code goes here
    sieve();
    int n; cin >> n;
    int res = n, i = 0;
    while (n > 1) {
      while (i < primes.size() && n % primes[i]) i++;
      if (i == primes.size()) break;
      res += (n /= primes[i]);
    }
    if (n > 1) res++;
    cout << res << endl;
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}

#include <stdio.h>
int main()
{
    int n, t1, i, ans, i1, tmp, p = 1;
    scanf("%d", &n);
    for (i = 1; i <= n; i ++)
     if (i * i >= n) {tmp = i; break;}
    if (i * i > n) tmp --;
    ans = n;  i = n;
    i1 = 2;
    while (p && n != 2)
    {
    p = 0;
    for (i = i1; i <= tmp; i ++)
     if (n == i) break;
     else
      if (n % i == 0) {
        ans += n / i;
        n = n / i;
        i1 = i;
        p = 1;
        break;
        }
     }
    ans ++;
    printf("%d", ans);
    return 0;
}

                                                  //author rhythmicankur
                                                  //god_is_almighty

#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#define ll long long
#define pb push_back
#define mk make_pair

using namespace std;
int main()
{
    ll a;
    cin>>a;
    ll s=a,k=a;
    ll i=2;
    for(ll i=2;i<=k;i++)
    {   if(a<1)
      break;
        while(a%i==0)
        {
            a=a/i;
            s=s+a;

        }

    }
    cout<<s;
    return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#define MAX 100007

using namespace std;

typedef long long LL;
int mark[MAX],n;
vector<int> p;

void init ( )
{
    p.push_back ( 2 );
    memset ( mark , -1 , sizeof ( mark ));
    for ( int i = 3 ; i < MAX ; i++ )
    {
        if (~mark[i]) continue;
        p.push_back ( i );
        for ( int j = 2*i  ; j < MAX ; j += i )
            mark[j] = i;
    }
}

int main ( )
{
    init ();
    int m = p.size();
    while (~scanf ( "%d" , &n ))
    {
        LL ans = 1;
        while ( n != 1 )
        {
            int pp = -1;
            for ( int i = 0; i < m && p[i]*p[i] <= n; i++ )
            {
                if ( n%p[i] ) continue;
                pp = p[i];
                break;
            }
            if ( pp == -1 ) pp = n;
            ans += n;
            n /= pp;
        }
        printf ("%d\n" , ans );
    }
}

#include <bits/stdc++.h>
using namespace std;
long long tmp, ans;
int main() {
	int n;
	cin >> n;
	ans = n;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans += n;
		}
	}
	ans += (n != 1);
	cout << ans;
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <set>
#include <queue>
#include <string>
#include <map>
#include <list>
#include <deque>
#include <algorithm>
using namespace std;
#pragma warning(disable:4996)
const double eps = 1e-7;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,i,j,a,b;
	long long s;
	cin >>n;
	s=(long long)n;
	while (n!=1)
	{
		for (a=2;a<sqrt(n*1.+eps);a++)
		{
			if (n%a==0)break;
		}
		if (n%a!=0)a=n;
		b=n/a;
		s+=(long long)b;
		n=b;
	}
	cout <<s;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <time.h>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <list>
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))

typedef long long ll;
typedef long double ld;
using namespace std;

bool point_left_from_line(ll x1, ll x2, ll poix, ll y1, ll y2, ll poiy)
{
    return (poix-x1)*(y2-y1)<(poiy-y1)*(x2-x1);
}
bool point_on_line(ll x1,ll x2, ll poix, ll y1, ll y2, ll poiy)
{
    return (poix-x1)*(y2-y1)==(poiy-y1)*(x2-x1);
}
bool point_on_circle(ll x, ll y, ll px, ll py, ld r)
{
    ld eps = 1e-12;
    if((px-x)*(px-x)+(py-y)*(py-y)-r*r<eps)return 1;
    else return 0;
}
bool point_into_circle(ll x, ll y, ll px, ll py, ld r)
{
    ld eps = 1e-12;
    if((px-x)*(px-x)+(py-y)*(py-y)<r*r-eps)return 1;
    else return 0;
}
ll ll_sign_0(ll x)
{
    if (x<0) return -1;
    if (x>0) return 1;
    if (x==0)return 0;
}

struct st
{
    ll num;
    ll t;
    int type;
};
    bool cmp(const st &a,const st &b)
    {
        if(b.t==a.t)
            return b.type==2;
        return b.t>a.t;

    }

ll maxdiv(ll x)
{
    ll n = (ll)sqrt((ld)x);
    ll res=1;
    for(ll i=2;i<=n;i++)
    {
        if(x%i==0){res=i;break;}
    }
    return res;
}

int main()
{
   //freopen("input.txt", "rt", stdin);
   //freopen("output.txt", "wt", stdout);
    ll n,res;
    cin >> n;
    res = n;
    ll div = maxdiv(n);
    while(div!=1)
    {
        n/=div;
        res+=n;
        div = maxdiv(n);
    }
    if(n!=1)res++;
    cout << res;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int smallestFactor(int n) {
  for (int i = 2; i < sqrt(n) + 2; i++) {
    if (n % i == 0) return i;
  }
  return n;
}

int main(int argc, char *argv[]) {
  int n;
  cin >> n;

  int sum = 0;
  while (n != 1) {
    sum += n;
    n /= smallestFactor(n);
  }

  sum += n;
  cout << sum << endl;
}

/**
 *    author:  Mohamed.Abo_Okail
 *    created: 23/12/2019
**/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

int main()
{
	std::ios_base::sync_with_stdio(0);
	ll n; cin >> n;
	ll ans = (n + 1);
	while(n) {
		ll i;
		for (i = (n - 1); i > 0; i--) {
			if(!(n % i)) break;
		}
		if(i == 1) { break; }
		ans += i;
		n = i;
	}
	cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
main(){
    long long int n,s=0;
    cin>>n;
    vector <long long int> a;
    a.push_back(n);
    for(int i=2;i<=n;i++){
        while(n%i==0){
            a.push_back(n/i);
            n=n/i;
        }
    }
    for(int i=0;i<a.size();i++){
        s+=a[i];
    }
    cout<<s;
}

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define ll long long int
#define pb push_back
#define loops(i, s, n) for (int i = s; i < n; i++)
#define loop(i, n) for (int i = 0; i < n; i++)
#define eps 1e-9
#define loopitr(mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vall(v) v.begin(), v.end()
#define mkp make_pair
#define ff first
#define ss second
const int mod = 1000000007;

ll modPow(ll a, ll b, ll mod)
{

    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }

    return res;
}

ll pow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

int d, x, y;
void ext_gcd(int a, int b)
{

    if (b == 0)
    {
        d = a;
        x = 1;
        y = 0;
    }

    else
    {
        ext_gcd(b, a % b);
        int temp = x;
        x = y; // here y is y1
        y = temp - (a / b) * y;
    }
}

ll numInv[10000000];
void modInvToN(ll n, ll m)
{ // modulo inv from 1 to n
    numInv[1] = 1;
    for (ll i = 2; i <= n; i++)
    {
        numInv[i] = (numInv[m % i] * (m - m / i)) % m;
        //numInv[i] += m;
    }
}

long long int farr[2];
void fib(long long int n) // fast fibonacci calc
{
    // TC = O(Logn)
    if (n == 0)
    {
        farr[0] = 0;
        farr[1] = 1;
        return;
    }

    fib(n >> 1);
    long long int c = farr[0] * (2 * farr[1] - farr[0]);
    long long int d = farr[0] * farr[0] + farr[1] * farr[1];

    if (n % 2 == 0)
    {
        farr[0] = c;
        farr[1] = d;
    }
    else
    {
        farr[0] = d;
        farr[1] = c + d;
    }
}

bool findSol(int A, int B, int C) // linear diophantine equation
{
    ext_gcd(abs(A), abs(B));
    int g = d;

    if (C % g != 0)
    {
        cout << "No solution" << endl;
        return false;
    }
    else
    {
        x *= C / g;
        y *= C / g;
        if (A < 0)
            x *= -1;
        if (B < 0)
            y *= -1;
        return true;
        cout << x << " " << y << endl;
    }
}

void shift_solution(int &x, int &y, int a, int b, int cnt)
{ // linear diophantine equation
    x += cnt * b;
    y -= cnt * a;
}

int numOfSol(int a, int b, int c, int minx, int maxx, int miny, int maxy)
{ // linear diophantine equation

    if (!findSol(a, b, c))
        return 0;
    int g = d;
    a /= g;
    b /= g;

    int sign_a = a > 0 ? +1 : -1;
    int sign_b = b > 0 ? +1 : -1;

    shift_solution(x, y, a, b, (minx - x) / b);
    if (x < minx)
        shift_solution(x, y, a, b, sign_b);
    if (x > maxx)
        return 0;
    int lx1 = x;

    shift_solution(x, y, a, b, (maxx - x) / b);
    if (x > maxx)
        shift_solution(x, y, a, b, -sign_b);
    int rx1 = x;

    shift_solution(x, y, a, b, -(miny - y) / a);
    if (y < miny)
        shift_solution(x, y, a, b, -sign_a);
    if (y > maxy)
        return 0;
    int lx2 = x;

    shift_solution(x, y, a, b, -(maxy - y) / a);
    if (y > maxy)
        shift_solution(x, y, a, b, sign_a);
    int rx2 = x;

    if (lx2 > rx2)
        swap(lx2, rx2);
    int lx = max(lx1, lx2);
    int rx = min(rx1, rx2);

    if (lx > rx)
        return 0;
    return (rx - lx) / abs(b) + 1;
}

int arr[10000000];
vector<int> primes;
void sieve()
{

    for (int i = 0; i < 10000000; i++)
        arr[i] = 1;
    arr[0] = 0;
    arr[1] = 0;

    for (int i = 2; i * i < 10000000; i++)
    {
        if (arr[i] == 1)
        {
            for (int j = i * i; j < 10000000; j += i)
            {
                arr[j] = 0;
            }
        }
    }

    for (int i = 0; i < 10000000; i++)
    {
        if (arr[i] == 1)
            primes.pb(i);
    }
}

void spf()
{
    for (int i = 0; i < 10000000; i++)
        arr[i] = 0;

    for (int i = 2; i * i < 10000000; i++)
    {
        if (arr[i] == 0)
        {
            for (int j = i * i; j < 10000000; j += i)
            {
                if (arr[j] == 0)
                    arr[j] = i;
            }
        }
    }

    for (int i = 2; i < 10000000; i++)
    {
        if (arr[i] == 0)
            arr[i] = i;
    }
}

int moduloInv(int a, int m) // using fermat little theorem
{
    return modPow(a, m - 2, m);
}

int modInv(int a, int m) // using ext_gcd
{
    int x, y;
    ext_gcd(a, m);
    int g = d;
    int res = (x % m + m) % m;
    return res;
}

int phi(int n)
{ // euler totient function
    int res = n;

    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            while (n % i == 0)
            {
                n /= i;
            }
            res -= res / i;
        }
    }

    if (n > 1)
        res -= res / n;

    return res;
}

int crt(int a[], int m[], int n)
{ // for n equations
    int m1 = m[0];
    int a1 = a[0];

    for (int i = 1; i < n; i++)
    {
        int a2 = a[i];
        int m2 = m[i];

        gcd(m1, m2);
        int ans = (a1 * m2 * y + a2 * m1 * x) % (m1 * m2);

        a1 = ans;
        m1 = m1 * m2;
    }

    if (a1 < 0)
        return a1 + m1;
    else
        return a1;
}

int main()
{

    fastio;

    ll n;
    cin>>n;

    ll ans  = n;
    for(ll i = 2;i*i<=n;i++){
        while( n % i == 0){
            ans += n/i;
            n/= i;
        }
    }

    if( n > 1)
      ans+=1;

    cout<<ans<<endl;
}

/**
 * @author neko13
 */
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
// 13C
#define DBG 0
#define sz(c) ((int)(c).size())
#define   forl(i, a, b) for(int i = (a); i <  (b); ++i)
#define  forle(i, a, b) for(int i = (a); i <= (b); ++i)
#define   forg(i, a, b) for(int i = (a); i >  (b); --i)
#define  forge(i, a, b) for(int i = (a); i >= (b); --i)
#define  forlc(i, a, b) for(int i##_b = (b), i = (a); i <  i##_b; ++i)
#define forlec(i, a, b) for(int i##_b = (b), i = (a); i <= i##_b; ++i)
#define  forgc(i, a, b) for(int i##_b = (b), i = (a); i >  i##_b; --i)
#define forgec(i, a, b) for(int i##_b = (b), i = (a); i >= i##_b; --i)
#define forall(i, v   ) forlc(i, 0,   sz(v))
#define forlla(i, v   ) forge(i, sz(v)-1, 0)
#define  forls(i, n, a, b) for(int i = a; i != b; i = n[i])
#define rep(n)  for(int               repp = 0; repp <    (n); ++repp)
#define repc(n) for(int repp_b = (n), repp = 0; repp < repp_b; ++repp)
#define rst(a, v) memset(a, v, sizeof a)
#define cpy(a, b) memcpy(a, b, sizeof a)
#define rstn(a, v, n) memset(a, v, (n)*sizeof((a)[0]))
#define cpyn(a, b, n) memcpy(a, b, (n)*sizeof((a)[0]))
#define pr(x) #x"=" << (x) << " | "
#define dout  DBG && cerr << __LINE__ << ">>| "
#define mk(x) DBG && cerr << __LINE__ << "**| "#x << endl
#define dlist(args...) DBG && (dout << #args", = ", (void)(dbgr, args), cerr << " |" << endl)
#define ast(b) if(DBG && !(b)) { fprintf(stderr, "%d!!|\n", __LINE__); while(1) getchar(); }
#define pra(arr, a, b) if(DBG) { \
    dout<<#arr"[] | "; \
    forlec(i, a, b) cerr<<"["<<i<<"]="<<arr[i]<<" |"<<((i-(a)+1)%13?" ":"\n"); \
    if(((b)-(a)+1)%13) cerr<<endl; \
  }
#define rd(type, x) type x; cin >> x
inline int     rdi() { int d; scanf("%d", &d); return d; }
inline char    rdc() { scanf(" "); return getchar(); }
inline string  rds() { rd(string, s); return s; }
inline double rddb() { double d; scanf("%lf", &d); return d; }
template<class T> inline bool setmin(T& a, T b) { return a>b? a=b, true: false; }
template<class T> inline bool setmax(T& a, T b) { return a<b? a=b, true: false; }
struct debugger { template<typename T> debugger& operator , (const T& x) { cerr << x << ","; return *this; } } dbgr;

typedef long long int64;

int n, ans;

int main() {
  ans = n = rdi();
  for(int64 i = 2; i*i <= n; ++i)
    while(n%i == 0)
      ans += n /= i;
  cout << ans+(n>1) << endl;
  return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int findMax(int &count,int n)
{
    int max=-1;
    if(n==2)
    {
      count=0;
    }
    else {
        for(int i=2;i<sqrt(n)+1;i++)
        {
            if(n%i==0)
            {
                max=n/i>max?n/i:max;
                count++;
            }
        }
    }
    return max;
}
int main()
{
    int n;
    cin>>n;
    long long sum=0;
    sum+=n;
    int count=0;
    while(true)
    {
       count=0;
       n=findMax(count,n);
       if(count!=0)
       {
          sum+=n;
       }
       else
       {
          break;
       }
    }
    cout<<sum+1<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i,n) for(ll i=0;i<n;i++)
#define inp(a,n)  for(ll i=0;i<n;i++)  cin>>a[i] ;
#define inpdd(a,n) f(i,n){f(j,n)cin>>a[i][j];}
#define sumv(a,n) ll s=0; for(ll i=0;i<n;i++) { cin>>a[i]; s+=a[i] };
#define otp(a,n)  for(ll i=0;i<n;i++)cout<<a[i]<<" ";
#define all(v) v.begin(),v.end()
#define bp(n)       __builtin_popcount(n)
#define max1(a)      *(max_element(a.begin(),a.end()))
#define min1(a)      *(min_element(a.begin(),a.end()))
#define ss second
#define ff first
#define fr(n) for(ll i=0;i<n;i++)
#define rs(a,n)   sort(a,a+n,greater<ll>())
const int MOD=1e9+7;
ll rvsr(ll n) {string s=to_string(n);  reverse(s.begin(),s.end());stringstream obj(s); obj>>n; return n; }
ll power(ll x, ll y){ll res=1;x=x;while(y>0){if(y&1)res = (res*x);y = y>>1;x = (x*x);}return res;}
ll logtwo(ll n){ if(n==1) return 0; return logtwo(n/2)+1;}
ll isprime(ll n ){for(ll c1 = 2; c1*c1 <= n ;c1++){    if(n%c1 == 0){return 0;}} return 1;}
ll twop(ll n) { ll x=0; while(n%2==0) {n/=2; x++;} return x;}
ll n,k,x=0,y=0; main( )
{
    IOS;
    cin>>n; ll sum=n+1;
    while(!isprime(n))
    {

       for(ll i=2;i*i<=n;i++)
          {if((n%i)==0)
            { n/=i; goto o;}}
        o: sum+=n;
        ;

    }
    cout<<sum;
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pi pair<ll,ll>
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007
#define base 1949313259

ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }

ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

ll bigmod(ll n,ll pow){
if(pow==0) return 1;
if(pow==1) return n%mod;

ll ans=bigmod(n,pow/2);
ans=(ans*ans)%mod;

if(pow%2==1){ans=(ans*n)%mod;}
return ans%mod;
}

ll fact[1000005];

ll nCr(ll n,ll r){

ll ans=fact[n];
ans=(ans*bigmod(fact[r],mod-2))%mod;
ans=(ans*bigmod(fact[n-r],mod-2))%mod;
return ans;
}

string s,s1,s2;
ll n,m;
ll arr[500010];
ll brr[500010];
vector<ll>v,v1;

map<ll,ll>mp;
ll vis[500005];

int main()
{__
        ll i,j,a,b,c,d,e,f,g,x,y,z,t,k,l;
        fact[0]=1;

      //  for(i=1;i<=1000000;i++) fact[i]=(fact[i-1]*i)%mod;
        ll ans=0;

        cin>>n;
         ans=n;
        for(i=2;i*i<=n;i++){
            while(n%i==0){
                n/=i;
                ans+=n;
            }
        }
        if(n!=1) ans++;
        cout<<ans<<endl;
}

#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <cctype>
#include <stdio.h>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n,ans=0;
	cin>>n;
	while(n>1) {
		int a=n;
		for(int i=2;i*i<=n;++i) {
			if(n%i==0) {
				a=i;
				break;
			}
		}
		ans+=n;
		n/=a;
	}
	cout<<ans+1;
    return 0;
}

#include<stdio.h>

int cari(int x){
    int i,ketemu=0,bil;
    for (i=2;i*i<=x;i++){
        if (x%i==0){
            bil=i;
            ketemu=1;
            break;
        }
    }
    if (ketemu==1) return bil;
    return -1;
}

int main(){
    int tot,i,sum=0,n,x;

    scanf("%d",&n);

    while (n!=0){
       sum += n;
       x = cari(n);
       if (x==-1){
           sum++;
           break;
       }
       else n/=x;
    }

    printf("%d\n", sum,cari(32));
    return 0;
}

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <sstream>

using namespace std;

int dp[55];

int calc(int n)
{
	if (dp[n] != -1) return dp[n];
	if (n == 1) return 1;
	int ret = 0;
	for (int i = 1; i < n; ++i)
	{
		if (n % i == 0)
		ret = max(ret, calc(i) + n);
	}
	return dp[n] = ret;
}

int main()
{
	memset(dp, -1, sizeof dp);
	int n; cin >> n;
	cout << calc(n) << endl;
	return 0;
}

#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#include <queue>
#include <functional>
#include <string>
#include <cctype>
#include <limits>

using namespace std;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef long double ld;
i64 n;
i64 sch = 0;

void rec(i64 n)
{
	if (n == 0) return;
	if (n == 1) { return; }
	if (n % 2 == 0) {
		sch += n/2;
		rec(n / 2);
		return;
	}
	i64 i = n / 2;
	for (; n%i != 0; i--);
	if (i == 0) i = 1;
	if (i == 1) {
		sch++; return;
	}
	sch += n-i;
	rec(n - i);
}

int main()
{

	cin >> n;
	i64 sch = n;
	for (i64 i = 2;n>01 ; i++)
	{
		if (n%i == 0){
			n /= i;
			sch += n;
			i = 1;
		}
	}
	cout << sch << endl;
	return 0;
}

// B.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

typedef long long int64;

int Del(int rvalue)
{
	int64 maxd = 0;
	double end = sqrt(double(rvalue));
	for (int i = 2; i <= end; i++)
	{
		int64 temp = rvalue / i;
		if (!(rvalue%i) && (temp > maxd))
		{
			maxd = temp;
		}
	}
	if (!maxd)
	{
		return 1;
	}
	else return maxd;
}

int main()
{
	int64 n, sum = 0;
	cin >> n;
	while (n != 1)
	{
		sum += n;
		n = Del(n);
	}
	sum += n;
	cout << sum << endl;
    return 0;
}

#include <iostream>
using namespace std;

int main() {
	long long n,res;cin>>n;res=n;
	while (n!=1) {
		long long i;for(i=2;i*i<=n;i++)if(n%i==0)break;
		if(n%i==0)n/=i,res+=n;
		else n=1,res++;
	}
	cout<<res<<endl;
	return 0;
}

//Mahir Ratanpara (DAIICT)
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

int tc;
#define tci cin>>tc
#define tcl while(tc--)

#define ll long long int
#define LLMax LONG_LONG_MAX
#define LLMin LONG_LONG_MIN

#define Ff(i,x,y) for(ll i=x;i<y;i++)
#define Fr(i,x,y) for(ll i=x;i>y;i--)

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound

int main(void)
{
	FAST;
	ll n;
    cin>>n;
    ll sum=n;

    for(ll i=2;i<=sqrt(n);i++)
    {
        while(n%i==0)
        {
            n=n/i;
            sum+=n;
        }
    }
    if(n>1)
    sum++;
    cout<<sum;
}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <iomanip>
#include <ctime>
#include <iostream>
#include <sstream>
#pragma comment(linker, "/STACK:256000000")

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
template<class T> inline T sqr(T a) {return a * a;}
#define INF 123456789
#define MOD 1000000007
#define PRIME 1103
#define TEST "test"

int next(int n)
{
	int res = 1;
	for(int i = 2; i * i <= n; ++i)
	{
		if(n % i) continue;
		res = max(res, max(i, n / i));
	}
	return res;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen(TEST ".in", "r", stdin);
	freopen(TEST ".out", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	int res = 0;
	while(n != 1)
	{
		res += n;
		n = next(n);
	}
	cout << res + 1;
	return 0;
}

#include<bits/stdc++.h>
//#include "header.h"
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
#define M 101

class algoritm
{
    friend istream &operator>>(istream &, algoritm &);
    friend ostream &operator<<(ostream &, const algoritm &);

public:

    void  rezolvare()
    {
        int x = n;
        int sum = 0;
        sum+=x;

        for(int i=2; i<=x; i++)
        {
            if(n%i==0 && i <= n)
            {
                while(n%i==0)
                {
                    n/=i;
                    sum+=n;

                }
            }
        }

        sum = (n!=1)? sum++ : sum;

        cout<<sum;

    }

protected:
    int n;

};

ostream &operator<<(ostream &output,const algoritm &alg)
{
    // output>>alg.rezolvare();
    return output;
}

istream &operator>>(istream &input, algoritm &alg)
{

    input>>alg.n;

    return input;

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    algoritm alg;
    cin>>alg;
    alg.rezolvare();

}

# include <stdio.h>
# include <math.h>

int a,i,sum,z;

int main()
{
	scanf("%d",&a);

	while(1)
	{
		z=a;

		for(i=2;i<=sqrt(a);i++)
		if(a%i==0)
		{sum=sum+a;a=a/i;i--;}

		if(z==a)
		{sum=sum+a;break;}
	}

	if(a!=1)
	sum++;

	printf("%d\n",sum);
}

#include<stdio.h>
#include<math.h>
#define N 100000
int n,f[N],prim[N],primNum=9592;

void initial()
{
    int i,j,rt;
    rt=(int)sqrt(N);
    for(i=0;i<N;i++) f[i]=1;
    f[0]=f[1]=0;
    for(i=2;i<=rt;i++)
        if(f[i])
            for(j=i*i;j<N;j+=i)
                f[j]=0;
    j=0;
    for(i=0;i<N;i++)
        if(f[i])
            prim[j++]=i;
    //for(i=0;i<10;i++) printf("prim [%d]=%d\n",i,prim[i]);
    //printf("j=%d\n",j);//9592

}

int isBigPrim(int n)
{
    int i,flag;
    flag=1;
    for(i=0;i<primNum;i++)
        if(n%prim[i]==0)
        {
            flag=0;
            break;
        }
    return flag;
}
int main()
{
    initial();
    int i,j,res;
    while(scanf("%d",&n)==1)
    {
        if(isBigPrim(n))
        {
            printf("%d\n",n+1);
        }
        else
        {
            res=n;
            while(n>1)
            {
                //printf("now n=%d\n",n);
                for(i=0;i<primNum&&prim[i]<=n;i++)
                    if(n%prim[i]==0)
                    {
                        //printf("here prim[%d]=%d n=%d\n",i,prim[i],n);
                        n/=prim[i];
                        res+=n;
                        i--;continue;
                    }
                    if(i==primNum){res+=1;break;}

            }
            printf("%d\n",res);
        }

    }
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

bool isprime(int k)
{
    bool ok=true;
    for (int j=2; j<=sqrt(k); j++)
    if (!(k%j)) ok=false;
    return ok;
}
int nd(int k)
{
    bool ok=true;
    for (int j=2; j<=sqrt(k); j++)
    if (!(k%j)) return j;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,ans=0;
    cin>>n;
    while(1)
    {
        ans+=n;
        n/=nd(n);
        if (isprime(n))
        {
            ans+=n;
            ans+=1;
            cout<<ans;
            return 0;
        }
    }
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	ll n,i,j;
    	ll sum;
    	cin>>n;
    	ll ans=n;
    	while(n>1)
    	{
    		int f=0;
    		for(i=2;i*i<=n;i++)
    		{
    			if(n%i==0)
    			{
    				f=i;
    				break;
				}
			}
			if(f)
			{
				n=n/f;
				ans+=n;
			}
			else
			{
				n=1;
				ans++;
			}
		}
    	cout<<ans;

    }

}

#include<bits/stdc++.h>
using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/

/*
unordered_map<int,int>mp;
mp.reserve(1024);
mp.max_load_factor(0.25);
*/

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    int ans=n;
    while(n>1){
        int val=n;
        for(int i=2;i*i<=n;i++){
            if(n%i==0){
                n=n/i;
                ans+=n;
                break;
            }
        }
        if(n==val){
            n=1;
            ans++;
        }
    }
    cout<<ans<<'\n';

    return 0;
}

#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <memory.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ul;

int getDiv(int a) {

    int b = ceil(sqrt(a));
    for(int i = 2; i <= b; ++i)
        if(a % i == 0)
            return i;

    return a;
}

int main(int argc, char** argv) {

    ios::sync_with_stdio(false);

    //ofstream cout("/home/unit7/output");
    //ifstream cin("/home/unit7/input");

    int n;
    cin >> n;

    ll ans = n;
    while(n > 1) {
        int div = getDiv(n);
        ans += n / div;
        n /= div;
    }

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int n;
int main()
{
    cin >> n;
    int ans = n;
    for(int i = 2; i * i <= n; i++)
        while(n % i == 0)
            n /= i, ans += n;
    cout << ans + (n > 1) << endl;
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input", "r", stdin);
        freopen("output", "w", stdout);
    #endif
    long long n,k;
    cin >> n;
    k = n;

    long long sum=n;

    for(int i = 2;i < sqrt(n) + 10;i++)
    {
      for(;k%i == 0;)
      {
         k = k / i;
         sum +=k;
      }
    }
     if (k != 1) sum++;
     cout << sum;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	ll n,sum=0;
	cin>>n;
	sum=n;
	while(1)
	{
		ll m=n;
		for(ll i=n/2;i>=2;i--)
			if(__gcd(i,n)!=1)
			{
				n=__gcd(i,n);
				sum+=__gcd(i,n);
				break;
			}
		if(n==m)
		{
			sum+=1;
			break;
		}
}
	cout<<sum;
}

#include <cstdlib>

#include <iostream>

using namespace std;

/*
 *
 */
int DoIt(){
    int n;
    cin >> n;
    int r=n;
    int d=2;
    int c = n;

    while(c>1){

        while((c%d !=0)){
            if(c<(d/2+1))
               ++d;
            else d = c;
        }
        c=c/d;
        r+=c;
    }
    cout << r;
    return 0;
}
int main(int argc, char** argv) {

    DoIt();

    return 0;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
const int MAX=(int)1e7+10;
bool ispr[MAX];
int pr[MAX],pn,n;
void init()
{
	memset(ispr,true,sizeof(ispr));
	for (int k=2; k<MAX; k++) {
		if (ispr[k]) pr[pn++]=k;
		for (int i=0; i<pn && k*pr[i]<MAX; i++) {
			ispr[k*pr[i]]=false;
			if (k%pr[i]==0) break;
		}
	}
}

int main()
{
	init();
	scanf("%d",&n);
	long long ans=n;
	int i=0;
	bool flag=false;
	for (int i=0; i<pn; i++) {
		if (n==pr[i]) {
			flag=true;
			break;
		}
	}
	while (n>1&&i<pn) {
		while (n%pr[i]==0) {
			ans+=(long long)n/pr[i];
			n/=pr[i];
		}
		i++;
	}
	if (i>=pn) flag=true;
	cout<<(flag?--ans:ans)<<endl;
	return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
const int maxn=40000;
int n;
int num[maxn],sum,Max,k;
bool mark[maxn];
void Gao()
{
    int i,j;
    memset(mark,false,sizeof(mark));
    k=0;
    for(i=2;i<maxn;i++)
    {
        if(!mark[i])
        {
            num[k++]=i;
            for(j=i*i;j<maxn;j+=i)
                mark[j]=1;
        }
    }
}
void dfs(int n)
{
    int i;
    for(i=0;i<k;i++)
    {
        if(num[i]>n)
            return ;
        if(n%num[i]==0)
        {
            sum+=n/num[i];
            dfs(n/num[i]);
            return ;
        }
    }
}
int main()
{
    int i;
    Gao();
    while(scanf("%d",&n)!=-1)
    {
        sum=n;
        dfs(n);
        if(sum==n) sum++;
        printf("%d\n",sum);
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int n;
 cin>>n;
 int a=n;
 vector<int> P;
 while(!(n&1))
  {P.push_back(2);
   n=n>>1;
  }
 bool b=false;
 for(int i=3;i<=n;i=i+2)
 {if(i*i>=n&&!b)
   break;
  while(n>1&&n%i==0)
   {P.push_back(i);
    n/=i;
    b=true;
   }
  if(n==1)
   break;
 }
 if(!b)
  P.push_back(n);
 n=P.size();
 int s=a;
 for(int i=0;i<n;++i)
 {a/=P[i];
  s+=a;
 }
 cout<<s;
 return 0;
}

#include<bits/stdc++.h>
using namespace std;

int n;

int main()
{
    cin >> n;
    long long ans = n;
    while(n != 1)
    {
        int flag = 0;
        for(int i=2;i<=max(2, (int)sqrt(n));i++)
        {
            if(n % i == 0)
            {
                ans += (long long)n / i;
                flag = 1;
                n -= (n / i);
            }
        }
        if(flag == 0)
        {
            ans += 1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int fa[20]={2,3,5,7,9,11,13,17,19,23,};
int judge(int n){
	for(int i=2;i<=(double)sqrt((double)n);i++)
		if(n%i==0)  return 0;
		return 1;
}

int main(){
	int n;

	cin>>n;
	if(judge(n)){
		cout<<n+1<<endl;
	}
	else
	{
		int k=0;
		int sum=n;
		while(1){
			while(n%fa[k]==0)
			   sum+=n/fa[k],   n=n/fa[k];
			k++;
			if(n==1) break;
			if(judge(n)) {   sum+=n; break;  }
		}

		cout<<sum<<endl;

	}

	return 0;

}

/**
 *    author:  Mohamed.Abo_Okail
 *    created: 24/12/2019
**/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

int main()
{
	std::ios_base::sync_with_stdio(0);
	ll n; cin >> n;
	ll ans = (n + 1);
	while(n) {
		if(n % 2 || (n / 2) == 1) { break; }
		ans += (n / 2);
		n /= 2;
	}
	cout << ans << endl;
}

#include <iostream>

using namespace std;
int  main()
{int res=0,cur;
int n;
cin>>n;
while (n%2==0){
	res+=n;
	n/=2;
}
if (n!=1) res+=n;
res+=1;
cout<<res<<endl;
return 0;
}

#include<iostream>
#include<stdio.h>
using namespace std;
int w[6600]={2,3,5,7,11,13,17,19,23,29};
bool isPrime(int n)
{
    for(int i=0; w[i]*w[i]<=n; ++i)
    if(n % w[i]==0) return false;
    return true;
}

int main()
{
    int n=10;
    int i,k,sum;
    for(i=31;i<(1<<16);i+=2)
        if(isPrime(i))
            w[n++]=i;
    while(scanf("%d",&k)!=EOF)
    {
        sum=k;
        for(i=0;i<n;i++)
        {
            while(!(k%w[i]))
            {
                k/=w[i];
                sum+=k;
            }
            if(k==1)
                break;
        }
        if(k!=1)
            sum+=k;
        printf("%d\n",sum);
    }
    return 0;
}

//177B
#include<cstdio>
#include<algorithm>
using namespace std;

int n, top, p[500000], cnt;
long long ans;
bool flag;

void play(int &n) {
  while (cnt <= top && n % p[cnt] != 0) cnt++;
  if (cnt > top || p[cnt] == n) {
    n = 1;
    return;
  }
  n = n / p[cnt];
}

int main() {
  top = 0;
  for (int i = 2; i <= 100000; i++) {
    for (int j = 1; j <= top; j++) {
      if (i % p[j] == 0) {
        flag = true;
        break;
      }
    }
    if (!flag) {
      top++;
      p[top] = i;
    }
  }
  scanf("%d", &n);
  if (n == 0) {
    printf("0\n");
    return 0;
  }
  ans += n;
  cnt = 1;
  while (n != 1) {
    play(n);
    ans += n;
  }
  printf("%I64d\n", ans);
  return 0;
}

//为了亲爱的张芯语努力奋斗！
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf INT_MAX
const double eps=1e-6;
inline int read(){
    int x=0,f=1;char ch =getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return x*f;
}
bool flag[10005];
int prime[10005],cnt,sum,N,p=1;
inline void init(){
	flag[1]=flag[0]=1;
	for(int i=1;i<=10002;i++){
		if(!flag[i])prime[++cnt]=i;
		for(int j=1;j<=cnt&&i*prime[j]<=10002;++j){
			flag[i*prime[j]]=1;		if(i%prime[j]==0)break;
		}
	}
}
inline int get(int x){
	for(;p<=cnt;p++)
	if(x%prime[p]==0)return prime[p];
	return x;
}
main(){
	init();sum=N=read();
	while(N!=1)N/=get(N),sum+=N;
	cout<<sum<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x=0;
    int answer = 0;
    while(1){
        answer += n;
        if(n%2==0){
            x=2;
        }
        for(int i=3;i*i<=n;i++){
            if(n%i == 0){
                x=i;
                break;
            }
        }
        n /= x;

        if(n<=1){
            break;
        }
    }
    answer+=1;
    cout<<answer<<"\n";
}

#include<bits/stdc++.h>

typedef long long ll;
using namespace std;
#define pi 3.1415926536
int func(int n){
    int f;
    f=(int)sqrt(n);
    for(int i=2;i<=f;i++){
        if(n%i==0)
            return (n-n/i);
    }
 return 1;
}

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,ans;
cin>>n;
ans=n;
while(n>1){
    //cout<<ans<<" "<<func(n)<<"\n";
    ans=ans+func(n);
    n=func(n);
}
cout<<ans;
}

#include <iostream>

using namespace std;

int main()
{
    int n; cin >> n;
    int sum=n;
    do {
        if(n%2!=0) break;
        sum+=n/=2;
    }
    while(n!=2);
    cout << sum+1 << endl;

    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
}
map<ll, ll>mem;
ll solve(ll x)
{
	if (mem.find(x) != mem.end())return mem[x];
	ll &ret = mem[x]; bool b = 0;
	for (int i =1; i <= sqrt(x); i++)
	{
		if (x%i == 0)
		{
			ret = max(ret, solve(x / i) + x);
			b = 1;
		}
	}
	if (!b)return x + 1;
	return ret;
}
int main()
{
	Mohammed_Atef_Hassan
		ll n;
	cin >> n;
	cout << solve(n) << finl;
}

#include <stdio.h>

int N,res;

int main(){

	scanf(" %d",&N);

	res=N;

	while(true){

		if(N%2){

			if(N>1) res++;
			break;

		}

		res+=N/2;
		N/=2;

	}

	printf("%d\n",res);

	return 0;

}

#include<bits/stdc++.h>
using namespace std;

#define MOD 1000000007
const int MAX = 1e5 + 7;
const int INF = 1e9;
long long t, n, m, a, b, c, d, u, v, f, k, x, y;
long long flag = 0, ans = 0, color = 0;

int MAIN()
{
        cin >> n;
        while(n > 1)
        {
                ans += n;
                bool isPrime = true;
                for(int i = 2; i * i <= n; ++i)
                {
                        if(n % i == 0)
                        {
                                n = n - n / i;
                                isPrime = false;
                                break;
                        }
                }
                if(isPrime)
                {
                        ans += 1;
                        break;
                }
        }
        cout << ans;
        return 0;
}

int main()
{
        ios_base::sync_with_stdio(false);
        #ifndef ONLINE_JUDGE
                freopen("in.txt", "rt", stdin);
                freopen("out.txt", "wt", stdout);
        #endif
        return MAIN();
}

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
      faster;
      ll int t,n,m,k,a,b=0,c,d,i,j,e,count=0,min,sum,x,y;
      cin>>n;
      a=n;
      while(1){
            if(n<=1)break;
            if(n%2==1){
                  m=sqrt(n);
                  if(m*m==n){
                        a+=m;
                        n=(n/m);
                  }
                  else{
                        for(i=m;i>=1;i--){
                              if(n%i==0){
                                    a+=i;
                                    n=i;
                                    break;
                              }
                        }
                  }
            }
            else{
                  a+=n/2;
                  n=n/2;
            }
      }
      cout<<a;
      return 0;
}

#include <bits/stdc++.h>
#define LIMIT 10000010

using namespace std;

int main () {

	long long n;

	cin >> n;

	long long ans=1;

	while (n>1) {
		ans+=n;
		long long bottom=sqrt(n);

		while (n%bottom!=0 && bottom>1) {
			bottom--;
		}

		long long top=n/bottom;
		if (bottom>1)
			n=max(bottom,top);
		else
			n=1;

	}

	cout << ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	ll n,sum=0;
	cin>>n;
	sum=n;
	while(n!=1)
	{
		if(n%2==0)
			sum+=n/2,n=n/2;
		else if(n%3==0)
			sum+=n/3,n=n/3;
		else
			n/=n,sum+=1;
	}
	cout<<sum;
}

#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#define FOR(i, start, end, growth) for (int i = start; i < end; i += growth)
#define RFOR(i, start, end, growth) for (int i = start; i >= end; i -= growth)
#define REP(i, end) FOR(i, 0, end, 1)
#define RREP(i, begin) RFOR(i, begin, 0, 1)

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;
typedef unordered_map<int, int> umap_ii;
typedef unordered_map<string, int> umap_si;

/**
 * Limits in C++ for reference
 * _____________________________________________________________________________________
 * |Sr| Macro Name | Description                     | Value
 * |No|____________|_________________________________|__________________________________
 * |1.| ULLONG_MAX | Maximum value unsigned long long|
 * 18,446,744,073,709,551,615 (10^20) |2.| LLONG_MAX  | Maximum value long long
 * | 9,223,372,036,854,775,807 (10^19) |3.| LLONG_MIN  | Minimum value long long
 * |-9,223,372,036,854,775,808 -1*(10^19) |4.| INT_MAX    | Maximum value int |
 * 2,147,483,647 (10^10) |5.| INT_MIN    | Minimum value int |-2,147,483,648
 * (10^10)
 */

// void solve(ll test_case)
// {
//     // Do your thing here :)
//     cout << test_case << "\n";
// }
// int a[1010];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ull n;
    cin >> n;
    ull s = n;
    while (n % 2 == 0 && n != 2)
    {
        n /= 2;
        s += n;
    }
    cout << s + 1 << endl;
    return 0;
}

#include<bits/stdc++.h>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define ll long long
using namespace std;
int sum;
map<int,int> m;
void func(int n)
{
	if(m.find(n)==m.end())
	{
		sum+=1;
		return ;
	}
	else
	{
		sum+=(n/(m[n]));
	//	cout<<sum<<" new sum\n";
		func((n/(m[n])));
	}
}
//void SieveOfEratosthenes(int n,int *prime)
//{
//    for (int p=2; p*p<=n; p++)
//    {
//        if (prime[p] == 0)
//        {
//            for (int i=p*p; i<=n; i += p)
//            	if(prime[i]==0)
//                	prime[i] = p;
//        }
//    }
//}
//void isPrime(int x)
//{
//	if(prime[x]==0)
//		cout<<"yes\n";
//	else
//		cout<<prime[x]<<" no\n";
//}
int main()
{
	int n;
	cin>>n;
//int prime[n+1]={0};
//	int x;
//	cin>>x;
//	SieveOfEratosthenes(n,prime);
for(int i=4;i<=n;i++)
{
	for(int j=2;j<=sqrt(i);i++)
	{
		if(i%j==0)
		{
			m[i]=j;
			break;
		}
	}
}
	sum +=n;
	func(n);
	//isPrime(x);
	cout<<sum;
}

#include <iostream>
using namespace std;
int main()
{
    int n {0},d=0;
    cin>>n;
    int c=n;
    while(n>1)
    {
        if (n%2==0)
        {
            c+=n/2;
            n=n/2;
        }
        else
        {
            if (n%3==0)
            {
                c+=n/3;
                n=n/3;
            }
            else
            {
                c+=1;
                break;
            }
        }
    }
    cout<<c;
}

#include<stdio.h>
void find(int x,int sum);
int max2=0;
int main()
{
    int num;
    scanf("%d",&num);
    find(num,0);
    printf("%d",max2);
    return 0;
}
void find(int x,int sum)
{
    for(int i=2;i<=(x+1)/2;i++)
    {
    if(x%i==0)
    {
    sum+=x;
    if(max2<sum+1)
    max2=sum+1;
    return find(x/i,sum);;
    }
    }
    max2=x+1;
    return;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
const int MAX=(int)1e7+10;
bool ispr[MAX];
int pr[MAX],pn,n;
void init()
{
	memset(ispr,true,sizeof(ispr));
	for (int k=2; k<MAX; k++) {
		if (ispr[k]) pr[pn++]=k;
		for (int i=0; i<pn && k*pr[i]<MAX; i++) {
			ispr[k*pr[i]]=false;
			if (k%pr[i]==0) break;
		}
	}
}

int main()
{
	init();
	scanf("%d",&n);
	long long ans=n;
	int i=0;
	bool flag=false;
	for (int i=0; i<pn; i++) {
		if (n==pr[i]) {
			flag=true;
			break;
		}
	}
	while (n>1&&i<pn) {
		while (n%pr[i]==0) {
			ans+=(long long)n/pr[i];
			n/=pr[i];
		}
		i++;
	}
	if (flag) ans--;
	cout<<ans<<endl;
	return 0;
}

# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
int main(void)
{
    int n;
    fi>>n;
    int ans = 0;
    for (int i = 2;i <= 1e8;++i)
        if (!(n%i))
            ans += n,n /= i;
    return fo << (++ans) << '\n',0;
}

#include<bits/stdc++.h>
using namespace std;

int n;

int main()
{
    cin >> n;
    int ans = n, pre = n;

    while(n != 1)
    {
        int flag = 0;
        for(int i=2;i<=max(2, (int)sqrt(n) + 2);i++)
        {
            if(n % i == 0 && (n / i) < pre)
            {
               // cout << i << " " << n / i <<endl;
                ans += (long long)n / i;
                flag = 1;
                pre = n / i;
                n -= (n / i);
                break;
            }
        }
        //cout << ans << " " << n <<endl;
        if(flag == 0)
        {
            if(pre != 1) ans += 1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;

bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

ll factorial(int n)
{
    ll x = 1e9+7;
    ll fact = 1, i;
    for(i = 1; i <= n ; i++)
        fact = (fact*i)%x;
    return fact;
}

int main() {
	ll n, sum = 0;
	cin>>n;
	while(n > 0)
	{
	    if(n == 1)
	    {
	        sum += 1;
	        n = n-1;
	    }
	    else if(n%2 == 0)
	    {
	        sum += n;
	        n = n/2;
	    }
	    else
	    {
	        sum += n;
	        n -= n-1;
	    }
	}
	cout<<sum;
	return 0;
}

// Author : deetav
// Happy stalking ! :P
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define ll long long
#define ld long double
#define endl "\n"

const ld PI = acos(-1);
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const int mod1 = 998244353;
const ll INF = 2e18;

#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++) //traverse through a dataset

template <class T>
inline void amin(T &x, const T &y)
{
    if (y < x)
        x = y;
}
template <class T>
inline void amax(T &x, const T &y)
{
    if (x < y)
        x = y;
}

ll Pow(ll a, ll b)
{
    if (a == 1 || b == 1)
        return a;
    if (b % 2 == 1)
        return (a * Pow(a, b - 1)) % MOD;
    return (Pow(a, b / 2) * Pow(a, b / 2)) % MOD;
}
/*
ll factorial(ll n) {
    ll ans = 1;
    while (--n)
        ans = (ans * (n + 1)) % MOD;
    return ans;
}*/
bool isPrime(int n)
{
    if (n <= 1)
        return false;

    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //test
    {
        int64_t n;
        cin>>n;
        int64_t c=0;
        c+=n;
        while(n%2==0){
            c+=n/2;
            n/=2;
        }
        while(n%3==0){
            c+=n/3;
            n/=3;
        }
        while(n%5==0){
            c+=n/5;
            n/=5;
        }
        while(n%7==0){
            c+=n/7;
            n/=7;
        }
        if(n==1){
            cout<<c;
        }else{
            cout<<c+1;
        }
    }
    return 0;
}

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <numeric>
using namespace std;

int nextInt() {
    int x;
    scanf("%d", &x);
    return x;
}

long long nextLong() {
    long long x;
    scanf("%I64d", &x);
    return x;
}

double nextDouble() {
    double x;
    scanf("%lf", &x);
    return x;
}

const int BUFSIZE = 1000000;
char buf[BUFSIZE + 1];
string nextString() {
    scanf("%s", buf);
    return buf;
}

struct Point {
    typedef double T;
    T x, y;
    Point () : x(0), y(0) {}
    Point (T x, T y) : x(x), y(y) {}
    Point operator - (Point op) const { return Point(x - op.x, y - op.y); }
    Point operator + (Point op) const { return Point(x + op.x, y + op.y); }
    Point operator * (T op) const { return Point(x * op, y * op); }
    T operator * (Point op) const { return x * op.x + y * op.y; }
    T operator % (Point op) const { return x * op.y - y * op.x; }
    T length2() { return x * x + y * y; }
    double lengt() { return sqrt(length2()); }
};

Point nextPoint() {
    double x = nextDouble();
    double y = nextDouble();
    return Point(x, y);
}

int FindMaxDiv(int n)
{
    static int max = 2;

    if(n <= 2)
        return 1;

    for (int i = max; i < (n/2)+1; ++i)
    {
        if (!(i & 1))
        {
            ++i;
        }
        int rem = n % i;
        if(rem == 0)
        {
            if (max < i)
            {
                max = i;
            }
            return n / i;
        }
    }
    return 1;
}

int main() {
    int n = nextInt();
    int sum = 0;
    while(n > 1)
    {
        //cout << n << endl;
        sum += n;
        n = FindMaxDiv(n);
    }
    sum++;

    cout << sum << endl;
    return 0;
}

///*Bismillahir Rahmanir Rahim***///
///**Author Thasin Sheikh**///
/*    #include <regex>
    ...
    std::string string("hello $name");
    string = std::regex_replace(string, std::regex("\\$name"), "Somename");
    */
/*while(a)
    {
        if(a%2==0)
            dvi.push_back(0);
        else
            dvi.push_back(1);
        a/=2;
    }
    reverse(dvi.begin(),dvi.end());*/
#include<bits/stdc++.h>
using namespace std;
vector<int>primes;
#define MAX 35000
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
bool fk[100000];
ll aarray[300000+10];
char magic[1][100000];
const int N = 2e5 + 10;
int main()
{
    makefast__
    string str,ptr;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,a,b,ans=0,i,l=0,A,B,C,D,E,cst,c,cd,d,j,k,x0,R,G;
    ll r,g;
    vector<ll>v;
    cin>>n;
    ans+=n;
    while(1)
    {
        if(n%2!=0)
        {
            if(n==1)
            cout<<ans<<endl;
            else cout<<ans+1<<endl;
            return 0;
        }
        else
        {
            n/=2;
            ans+=n;
        }
       // cout<<n<<" "<<ans<<endl;

    }
    //cout<<ans<<endl;

}

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
const int MAX=(int)1e7+10;
bool ispr[MAX];
int pr[MAX],pn,n;
void init()
{
	memset(ispr,true,sizeof(ispr));
	for (int k=2; k<MAX; k++) {
		if (ispr[k]) pr[pn++]=k;
		for (int i=0; i<pn && k*pr[i]<MAX; i++) {
			ispr[k*pr[i]]=false;
			if (k%pr[i]==0) break;
			//cos for m=k*pr[j](j>i),k%pr[i]==0,
			//thus, pr[i]|m, so there is no need
			//to continue the siezing process
		}
	}
}

int main()
{
	init();
	scanf("%d",&n);
	long long ans=n;
	int i=0;
	while (n>1&&i<pn) {
		while (n%pr[i]==0) {
			ans+=(long long)n/pr[i];
			n/=pr[i];
		}
		i++;
	}
	cout<<ans<<endl;
	return 0;
}

#include <iostream>
using namespace std;
int p[10]={2,3,5,7,11,13,17,19,23,29};
int main()
{
	int n;
	cin>>n;
	int ans=0;
	while( n >  0)
	{
		ans+=n;
		if(n==1)
			break;
		bool flg=0;
		for(int i=0;i<10;i++)
		{
			if(n==p[i])
			{
				flg=0;
				break;
			}
			if(n%p[i]==0)
			{
				n/=p[i];
				flg=1;
				break;
			}
		}
		if(flg==0)
			n=1;
	}
	cout<< ans << endl;
}

#include <iostream>
#include <cmath>

int main() {
	size_t n;
	std::cin >> n;
	size_t ansv = n;
	while(n != 1) {
		size_t del;
		for(del = 2; del <= (size_t)sqrt(n) + 1; ++del) {
			if(n % del == 0)
				break;
		}
		n = n / del;
		ansv += n;
	}
	std::cout << ansv;
	return 0;
}

#include<iostream>
#include<stdio.h>
#include<map>
#include<vector>
using namespace std;
int n;
map<int,int>mp;
vector<int>fact;
int calc(int rem){
    if(rem==1)
        return 0;
    if(mp.find(rem)!=mp.end())
        return mp[rem];
    int best=0;
    for(int i=0;i<fact.size();++i)
        if(rem%fact[i]==0)
            best=max(best,calc(rem/fact[i])+rem/fact[i]);
        else if(rem>fact[i])
            break;
    return mp[rem]=best;
}
int main(){
    cin>>n;
    int g=n;
    int i=2;
    while(i*i<=g){
        if(g%i==0)
            fact.push_back(i);
        while(g%i==0)
            g/=i;
        ++i;
    }
    if(g!=1)
        fact.push_back(g);
    cout<<calc(n)+n<<endl;
}

#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fill(x,y) memset(x,y,sizeof(x))

int main(){
    int n;
    scanf("%d",&n);
    long long  answer=0;
    if(n%2!=0){
        cout<<n<<endl;
        re 0;
    }
    while(1){

        answer+=n;
        for(int i=n/2;i>=1;i--){
            if(n%i==0){
            n=i;
            break;
            }

        }
        if(n==1){
            answer+=1;
            break;
        }

       // cout<<answer<<","<<n<<endl;

    }
//    cout<<s<<endl;
    printf("%ld\n",answer);
    re 0;
}

#include <vector>
#include <iostream>

using namespace std;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	long int ans;
	long int n;
	cin>> n;
	ans = n;
	int a=2;
	while (a<n/2){
		while(n%a!=0){if(a!=2) a+=2;else a++;}
		n=n/a;
		ans+=n;
	}
	cout<<ans+1;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int n;

int main()
{
    cin >> n;
    int ans = n;
    while(n != 1)
    {
        int flag = 0;
        for(int i=2;i<=max(2, (int)sqrt(n));i++)
        {
            if(n % i == 0)
            {
                ans += n / i;
                flag = 1;
                n -= (n / i);
            }
        }
        if(flag == 0)
        {
            ans += 1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll sum=n;
   // cout<<n<<"  ";
    while(n>1)
    {//  cout<<n<<"  "<<sum<<"\n";

        if(n%2==0)
          {sum+=(n/2); n=n/2;}
        else
        {
            for(ll i=3;i*i<=n;i+=2)
            {
                if(n%i==0)
                {
                    sum+=(n/i);
                    n/=i;
                    break;
                }
            }

            sum+=1;
            n=0;

        }

    }
    cout<<sum;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,sum;
    cin>>n;
    sum=n;
    while(1){
        if(n%2==0){
            n=n/2;
            sum+=n;
            if(n==1) break;
        }else{
            sum++;
            break;
        }
    }
    cout<<sum;
    return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
         ll n;
         cin>>n;
         ll ans=n;
         while(n>1){
                  if(n%2!=0){
                           ans=ans+1;
                           break;
                  }
                  else if(n%2==0){
                           ans=ans+(n/2);
                           n=n/2;
                  }
         }
         cout<<ans<<endl;
}

#include<bits/stdc++.h>
#include<vector>
//#include <boost/algorithm/string.hpp>
using namespace std;
#define lli long long int
#define test                lli t;cin>>t;while(t-->0)
#define ainput  int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define vec vector<lli>v;
vec
#define avinput  int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];v.push_back(a[i]);}
#define vp  for(lli i=0;i<v.size();i++) {cout<<v[i]<<" ";}cout<<endl;
#define vp1  for(lli i=0;i<v1.size();i++) {cout<<v1[i]<<" ";}cout<<endl;
#define vp2  for(lli i=0;i<v2.size();i++) {cout<<v2[i]<<" ";}cout<<endl;
#define vp3  for(lli i=0;i<v3.size();i++) {cout<<v3[i]<<" ";}cout<<endl;
#define vp6  for(lli i=0;i<v6.size();i++) {cout<<v6[i].first<<" "<<v6[i].second<<endl;}
#define vp16  for(lli i=0;i<v16.size();i++) {cout<<v16[i].first<<" "<<v16[i].second<<endl;}
#define ln cout<<endl;
  //cout << fixed << setprecision(10) <<((double)((sum*1.0)/((n*1.0-k*1.0)+1.0))) << endl;
set<lli>s1;
set<lli>s2;
set<string>st2;
vector<lli>v1;
vector<lli>v2;
vector<lli>v3;
vector<lli>v4;
vector<lli>v5;
vector<pair<lli,lli> >v6;
vector<pair<lli,lli> >v16;
vector<string>v7;
vector<string>v8;
vector<char>v9;
vector<char>v99;
set<char>s11;
set<char>s22;
vector<double>v11;
list<lli>l;
//****coding start****
vector<lli>b[10];

int main(){
lli n;
cin>>n;
lli sum=n;
lli c;
while(c>0){
        c=0;
    for(lli i=2;i<=sqrt(n);i++){
        if(n%i==0){
            sum=sum+(n/i);
            n=n/i;
            c++;
            break;
        }
    }
}
cout<<sum+1<<endl;
return 0;
}

#include < stdio.h >
#include < string >
#include < iostream >
#include < fstream >
#include <sstream>
using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	int num;
	cin >> num;
	int k = num;
	int res(0);
	res += k;
	while(1)
	{
		int cur;
		for (int i = 2; i < num+1; i++)
			if ((k % i) == 0)
			{
				cur = k/i;
				k = k - (k/i);
				cout << k << endl;
				res += k;
				break;
			}
		if (k == 1) break;
		if (cur == 1)
		{
			res -= k;
			res += 1;
			break;
		}
	}
	cout << res;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin>>n;
  if(n%2){
    cout<<n+1<<endl;
  }else{
    int count=0;
  while(n%2==0){
    count+=n;
    n=n/2;
  }
  if(n>1){
  count+=n;
  count++;
  }else
  count++;
  cout<<count<<endl;
  }
}

#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int ans = n;
    while(n > 1){
        for(int i = sqrt(n);i >= 1;i--){
            if(n % i == 0){
                if(i == 1){
                    ans += 1;
                    n = 1;
                } else {
                    ans += n / i;
                    n = n / i;
                }
                break;
            }
        }
    }
    cout << ans;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,sum;
    cin>>n;
    sum=n;
    while(n)
    {
        if(n%2==0)
        {
            sum=sum+n/2;
            n=n/2;
        }
        else if(n!=1)
        {
            sum=sum+1;
            cout<<"yo:  ";
            break;
        }
        if(n==1)
        break;
    //    cout<<"sum:  n:  "<<sum<<" "<<n<<endl;
    }
    cout<<sum<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int n;

int main()
{
    cin >> n;
    long long ans = n;
    while(n != 1)
    {
        int flag = 0;
        for(int i=2;i<=max(2, (int)sqrt(n));i++)
        {
            if(n % i == 0)
            {
                ans += (long long)n / i;
                flag = 1;
                n -= (n / i);
            }
        }
        if(flag == 0)
        {
            ans += 1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int isprime[100];
vector<int> primes;

int main()
{

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;

    for(int i = 0 ; i < 100 ; i++)
        isprime[i]=1;

    isprime[0]=isprime[1]=0;

    for(int i = 2 ; i < 100 ; i++){
        if(isprime[i])
            primes.push_back(i);
            for(int j = i * i ; j < 100 ; j+=i){
                isprime[j]=0;
            }
    }

    ll idx=0;
    ll temp=n;
    ll ans=n;
    while(isprime[n]!=1&&idx<temp){
        while(n%primes[idx]==0){
            ans+=n/primes[idx];
            n/=primes[idx];
        }
        idx++;
    }

    cout<<ans+1<<endl;

    return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <deque>
#include <algorithm>
#include <ctype.h>
#include <string>
#include <map>

using namespace std;

bool isPrime(int n) {
	if (n == 2) {
		return true;
	}
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

int findPair(int n) {
	// n is not prime
	for (int i = sqrt(n); i > 1; i--) {
		if (n % i == 0) {
			// found. (i, n/i)
			// return max of this
			return max(i, n / i);
		}
	}
	return 1;
}

int main() {
	int n;
	cin >> n; // number of pebbles
	// if prime, -> 1 (end)
	// if not prime, find a factor pair closest to sqrt(n)
	//				then take the largest of the pair

	int sum = n;
	int temp = 0;
	while (n > 1) {
		if (isPrime(n)) {
			sum += 1; // prime, so add itself and 1 and break
			break;
		}
		else {
			// find pair
			temp = findPair(n);
			sum += temp;
			n = temp;
		}
	}
	cout << sum;

}

#include<bits/stdc++.h>
using namespace std;
int fact(int n)
{
    int total=0;
    if(n==1)
        return (1);
    else{
    for(int i=n;i>=1;i--)
    {
        if(n%i==0)
        total=total+i;
    }
    return (total);
    }
}
int main()
{
    int n,c1,sum,maximum=0;
    cin>>n;
    for(int i=1;i<n;i++)
    {
        //int i=4;
        c1=n;
        sum=0;
        if(n%i==0)
        {

           sum=c1+fact(i);
        }
        if(maximum<sum)
            maximum=sum;
    }
    cout<<maximum;
}

#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable:4786)

#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <ctime>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cctype>
#include <string>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <numeric>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define MAX_SIZE 100100
#define MAX_LENGTH 111
#define INF ( 1 << 29 );

#define CLR( a ) memset( a , NULL , sizeof( a ) )
#define MEM( a ) memset( a , -1 , sizeof( a ) )
#define fort( a , b ) for( ind = ( a ); ind <= ( b ); ind++ )
#define foriab( a , b ) for( i = ( a ); i < ( b ); i++ )
#define fori( a ) for( i = 0; i < ( a ); i++ )
#define forj( a ) for( j = 0; j < ( a ); j++ )
#define print1( a ) printf( "%d ---\n" , ( a ) )
#define print2( a , b ) printf( "%d %d ---\n" , ( a ) , ( b ) )

typedef __int64 lll ;

int MIN( int a , int b ) { return a < b ? a : b ; }
int MAX( int a , int b ) { return a > b ? a : b ; }
int GCD( int a , int b ) { while( b ) b ^= a ^= b ^= a %= b ; return a ; }
int LCM( int a , int b ) { return a * ( b / GCD( a , b ) ) ; }
void SWAP( int &a , int &b ) { a = a ^ b ; b = a ^ b ; a = a ^ b ; }

const double PI = acos( -1 ) ;
const double EPS = 1e-11 ;

int arr[ MAX_LENGTH ][ MAX_LENGTH ] , brr[ MAX_LENGTH ][ MAX_LENGTH ] ;

int main() {
    //freopen( "A.in" , "r" , stdin ) ;
	//freopen( "out.txt" , "w" , stdout ) ;
	int T , res , n , i , ind ;
	while( scanf( "%d" , &n ) != EOF ) {
        CLR( arr ) ;
        CLR( brr ) ;
        int j ;
        fori( n ) {
            forj( n ) {
                scanf( "%d" , &arr[ i ][ j ] ) ;
            }
        }
        int x , y ;
        x = 0 ;
        y = 0 ;
        while( 1 ) {
            brr[ x ][ y ] = 1 ;
            x++ ;
            y++ ;
            if( x >= n || y >= n ) { break ; }
        }
        x = 0 ;
        y = n - 1 ;
        while( 1 ) {
            brr[ x ][ y ] = 1 ;
            x++ ;
            y-- ;
            if( x >= n || y < 0 ) { break ; }
        }
        int cn = 0 ;
        fori( n ) {
            if( cn == ( ( n - 1 ) / 2 ) ) {
                forj( n ) {
                    brr[ i ][ j ] = 1 ;
                }
                break ;
            }
            cn++ ;
        }
        cn = 0 ;
        forj( n ) {
            if( cn == ( ( n - 1 ) / 2 ) ) {
                fori( n ) {
                    brr[ i ][ j ] = 1 ;
                }
                break ;
            }
            cn++ ;
        }
        res = 0 ;
        fori( n ) {
            forj( n ) {
                if( brr[ i ][ j ] == 1 ) {
                    res += arr[ i ][ j ] ;
                }
            }
        }
		printf( "%d\n" , res ) ;
	}
	return 0 ;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>

#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

#define unlli unsigned long long int
#define lli long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FOR1(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=n-1;i>=0;i--)
#define P printf
#define sc scanf
#define ms memset

void solve();

int main(){
    #ifdef LOCAL_TEST
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    solve();

    return 0;
}

const int N=100000;

void solve(){
    int n;
    scanf("%d",&n);

    unlli sum=n;
    unlli i=2,j;
    while(i<=n){
        if(i==n){
            sum+=1;
            break;
        }

        if(n%i==0){
            j=i;
            while(n%i==0){
                i*=j;
            }
            i/=j;
            n/=i;

            if(i==j){

                sum+=n;

            }else{

                sum+=1LL*n*(i-1);

            }

            i=j;
        }
        i++;
    }

    cout<<sum;
}

#include <iostream>
#include <unordered_map>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define ll long long
#define v vector
#define pb push_back
#define f first
#define s second
#define bcnt __builtin_popcount
#define gcd __gcd
const int MAX = (ll)1e5;
const ll rem = (ll)1e9+7;

// v<bool> Sieve() {
//   v<bool> hash(MAX+1,true);

//   for (int i = 2; i * i < MAX+1; i++)
//   {
//     if (!hash[i])
//       continue;
//     for (int j = i * i; j < MAX+1; j += i)
//     {
//       hash[j] = false;
//     }
//   }
// return hash;
// }

// bool isPrime(ll n)
// {
//   if (n <= 3)
//     return true;

//   if (n % 2 == 0 || n % 3 == 0)
//     return false;

//   for (ll i = 5; i * i <= n; i = i + 6)
//     if (n % i == 0 || n % (i + 2) == 0)
//       return false;

//   return true;
// }

// v<v<int>> vec;
// v<v<char>> carr(100,v<char>(100,'0'));
// void permute(v<int>& arr, int l, int r)
// {
//   if (l == r)
//   {
//     vec.pb(arr);
//     return;
//   }

//   for (int i = l; i <= r; i++)
//   {
//     swap(arr[l], arr[i]);
//     permute(arr, l + 1, r);
//     swap(arr[l], arr[i]);
//   }
// }

ll binomialCoeff(int n, int k)
{
  ll res = 1;

  if (k > n - k)
    k = n - k;
  for (int i = 0; i < k; ++i)
  {
    res *= (n - i);
    res /= (i + 1);
  }

  return res;
}

int n;
int m;
int t;
int k;
int a;
int b;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 cout.tie(NULL);
 cin>>n;
ll ans=n;
while(n>1){

if(n%2==0){
  while(n%2==0){
   ans+=n/2;
   n/=2;
  }
}else{
  int num=1;
  for(int i=3;i*i<=n;i+=2){
     if(n%i==0){
       num=max(num,max(i,num/i));
     }
  }
  if(num==1){
    ans+=num;break;
  }else{
    ans+=num;
    n=num;
  }
}
}
cout<<ans;

return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n,i,j,s;
int main()
{
	cin>>n;
	s=n;
	while(n>1)
	{
		if((sqrt(n)*sqrt(n))==n && n%2==1)
		{
			s+=sqrt(n);
			n=sqrt(n);
		}
		else if(n%2==1 || n==2)
		{
			s++;
			n=0;
		}
		else
		{
			s+=(n/2);
			n/=2;
		}
	}
	cout<<s;
}

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll n;
    cin>>n;
    ll sum=n;
   // cout<<n<<"  ";
    while(n>1)
    {//  cout<<n<<"  "<<sum<<"\n";

        if(n%2==0)
          {sum+=(n/2); n=n/2;}
        else
        {
            for(ll i=3;i*i<=n;i+=2)
            {
                if(n%i==0)
                {
                    sum+=i;
                    n/=i;
                    break;
                }
            }

            sum+=1;
            n=0;

        }

    }
    cout<<sum;
    return 0;
}

#include <iostream>
#include<math.h>
#include<algorithm>
using namespace std;

bool *is_prime;
long long int max_factor(long long int a)
{
    for(int i = 2;i<=sqrt(a);i++)
    {
        if(is_prime[i])
        {
            if(a%i == 0)
            return a/i;
        }
    }
    return 1;
}
long long int get_num(long long int a)
{
    if(a==1)
    return 1;
     long long int num = 0;
    num+= a+get_num(max_factor(a));
    return num;
}

int main() {
    long long int n;
    cin>>n;
    is_prime = new bool[(long int)sqrt(n)];
    long int l = sizeof(is_prime)/sizeof(is_prime[0]);
    fill_n(is_prime,l,1);
    for(int i = 2;i<=sqrt(l);i++)
    {
        if(is_prime[i] == true)
        {
            for(int j = pow(i,2);j<=l;j++)
            {
                is_prime[j] = false;
            }
        }
    }

    cout<<get_num(n);

    return 0;
}

#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;

bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second>b.second);
}

void solve()
{

 int n,m;
 cin>>n;

 ll cnt=n;
 while(n>1)
 {
    int flag=0;
    if(n&1)
    {

        for(int i=3;i*i<=n;i+=2)
        {
            if(n%i==0)
            {
                cnt+=i;
                n/=i;
                flag=1;
                break;
            }
        }
        if(!flag)
        {
            cnt++;
            break;
        }

    }

    else
    {
        n/=2;
       cnt+=n;

    }
//cout<<cnt<<endl;
 }
 cout<<cnt<<endl;
}

 main()
{
    /*int t;
    cin>>t;

   while(t--)*/

    solve();

}

#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char*argv[]) {
	bool yes = false;
	int n;
	unsigned int a, b, s = 0;
	cin >> n;
	b = n;

	for(int i = 2; i <= b/2 + 1; (i == n-1 || i == 2)?(++i):(i += 2)) {
		yes = false;
		while(b % i == 0) {
			yes = true;
			s += b;
			a = i;
			b /= i;
		}
	}

	if(!yes) s += b;

	cout << s + 1 << endl;

	return 0;
}

#include <iostream>

using namespace std;

int main(){
int n;
cin >> n;
int result = n;
while(n % 2 == 0 && n / 2 != 1){
n /= 2;
result += n;
}
result += 1;
cout << result << endl;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,sum;
    cin>>n;
    sum=n;
    while(n)
    {
        if(n%2==0)
        {
            sum=sum+n/2;
            n=n/2;
        }
        else if(n!=1)
        {
            sum=sum+1;
         //   cout<<"yo:  ";
            break;
        }
        if(n==1)
        break;
    //    cout<<"sum:  n:  "<<sum<<" "<<n<<endl;
    }
    cout<<sum<<endl;
    return 0;
}

//Let the stars shine upon me
#include<bits/stdc++.h>
using namespace std;
//~~~  Newly Defined Keywords  ~~~
#define ll long long
#define ull unsigned long long
#define maxm 100005
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pi acos(-1)
#define runtest(t) scanf("%llu",&t); for(int test=1; test<=t; test++)
#define testcase printf("Case %llu: ",test)
#define mod 10000007

int main()
{
    int n;
    cin>>n;
    int sum=n;
    while(n%2==0)
    {
        sum+=(n/2);
        n/=2;
    }
    if(n>1)
        sum++;
    cout<<sum<<endl;
}

#include <iostream>
#include <cmath>
using namespace std;

int findHF(int x){
	int HF = 1;
	for (int i = 2; i <= sqrt(x); i++){
		if (x%i == 0) HF = i;
	}
	return HF;
}
int main(){
	int x;
	cin >> x;

	int sum = 0;
	while (x > 1){
		sum += x;
		int HF = findHF(x);
		if (HF != 1) x = x/HF;
		else x = 1;
	}
	sum++;
	cout << sum;
}

#include <iostream>
using namespace std;
int main()
{
    int n {0},d=0;
    cin>>n;
    int c=n;
    while(n>1)
    {
        if (n%2==0)
        {
            c+=n/2;
            n=n/2;
        }
        else
        {
            if (n%3==0)
            {
                c+=n/3;
                n=n/3;
            }
            else if (n%5==0)
            {
                c+=n/5;
                n=n/5;
            }
            else
            {
                c+=1;
                break;
            }
        }
    }
    cout<<c;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mpp make_pair
#define mod 1000000007
#define inf 9000000000000000000LL
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    fast;
    ll n,f=0,sum=0;
    cin>>n;
    while(n>1)
    {
        if(n%2!=0)
        {
            sum+=n;
            f=1;
            break;
        }
        else
        {
            sum+=n;
            n=n/2;
        }

    }
    if(f==1)
    {
        for(ll i=n-2; i>=3; i-=2)
        {
            if(n%i==0)
            {
                sum+=i;
                break;
            }
        }
    }
    cout<<sum+1<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pp pair<int, int>
#define mx 1000

int main()
{
    int n;
    cin >> n;
    int res = n;
    while(n != 1)
    {
        if(n%2 == 0)
        {
            n = n/2;
            res += n;
        }
        else
        {
            int x = round(sqrt(n));
            if(x*x == n)
            {
                res += x;
                n /= x;
            }
            else
            {
                n = 1;
                res += 1;
            }
        }
    }
    cout << res << endl;
}

#include <vector>
#include <iostream>

using namespace std;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	long int ans;
	long int n;
	cin>> n;
	ans = n;
	int a=2;
	while (a<n/2){
		while(n%a!=0){if(a!=2) a+=2;else a++;}
		n=n/a;
		ans+=n;
	}
	cout<<ans+1;
	return 0;
}

#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<ctime>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)

using namespace std;

#define pb push_back
#define pf push_front
#define p_f pop_front
#define p_b pop_back
#define LL __int64
#define LD long double
#define MP make_pair
#define fi first
#define se second
#define sc scanf
#define pr printf
#define str strlen
LL a,b,i,j,k,n,m;
LL cnt=1,fl=0,a2,a3=-1000000,i1,ans=0;//456345677
main()
{
    sc("%I64d",&n);
    b=n;
    while(1)
    {
        for(i=2;i*i<n;i++)
        {
            if(n%i==0){fl=1;ans+=(n/i);break;}
        }
        if(fl==0){pr("%I64d\n",ans+b+1);return 0;}
        fl=0;
        n=(n/i);
    }
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
using namespace std;

// <editor-fold defaultstate="collapsed" desc="Defines">

typedef long long ll;
typedef unsigned long long ull;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
const double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
#define REP(to, counter) for (int counter=0; counter < int(to); counter++)
#define X first
#define PB push_back
#define MP make_pair
#define Y second
#define eps 1E-7

inline vi ReadVI(int count)
{
    vi arrayname(count);
    REP(count, i) cin >> arrayname[i];
    return arrayname;
};

inline vii ReadVII(int count)
{
    vii arrayname(count);

    REP(count, i)
    {
        cin >> arrayname[i].first;
        arrayname[i].second = i;
    }
    return arrayname;
};

const int MOD = 1000000007;
const int MAXVALUE = 100001;

// </editor-fold >

vi sieve(int n)
{
    int *r = new int[n]();
    r[0] = r[1] = 1;
    for (int i = 1; i < sqrt(n); i++) {
        if (r[i] == 0) {
            for (int j = i; j < n; j += i) r[j] = 1;
            r[i] = 0;
        }
    }
    vi res;
    for (int i = 0; i < n; i++) {
        if (r[i] == 0) res.push_back(i);
    }

    delete[] r;
    return res;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    vi pr = sieve(1000);
    ll res = 0;
    while (n > 1) {
        res += n;
        int i = 0;
        bool flag = false;
        for (; i < pr.size() && pr[i] * pr[i] <= n; i++) {
            if (n % pr[i] == 0) {
                flag = true;
                break;
            }
        }
        if (flag) n /= pr[i];
        else n = 1;
    }
    cout << res + 1;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1e5 + 11;
const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    ll m=n;
    vector<ll> p;
    ll d=2;
    while (d*d<=n)
    {
        if (n%d==0) {n/=d;p.pb(d);} else d++;
    }
    if (n>1) p.pb(d);
    ll ans=m;
    for (int j=0; j<p.size(); j++)
    {
        m/=p[j];
        ans+=m;
    }
    cout<<ans<<endl;
}

#include <string.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef pair<int,int>ii;
const int oo=INT_MAX;
long long f(long long n)
{
    if(n==1)
    return 0;
    long long ret=0;
    double a=sqrt(n);
    long long x=a*100;
    for(long long i=x;i>=1;i--)
    {
     if(n%i==0&&i!=n)
     {
        ret+=f(i)+i;
        break;
     }
    }
    return ret;
}
int main()
{
  //freopen("test.in","r",stdin);
  long long n;
  cin>>n;
  cout<<f(n)+n;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d,n,i,k=1e9,m,j,ans=0;
	cin>>n;
	ans=n;
	while(k--){
		b=n;
		for(i=2; i<=sqrt(n)+1; i++){
			if(n%i==0){
				ans+=n/i;
				n=n/i;
				break;
			}
		}
		if(b==n){
			cout<<ans+1;
			exit(0);
		}
	}
}

# include <stdio.h>
# include <math.h>
int n,k;
int ans=0;
int main()
{
scanf("%d",&n);
ans=n;
k=sqrt(n);
while(n != 1)
{
int q=0;
for(int i=2;i<=k;i++)
if(n%i==0) n=n/i,q=1;
if(q==0) n=1;
ans+=n;
}
printf("%d\n",ans);
}

#include<iostream>
using namespace std;
int main()
{
int n;cin>>n;int sum=n;int i=2;
while(i<n && n>1){
    if(n%i==0){sum+=n/i;
    i=2;n/=i;
}
else i++;
}
cout<<sum+1;
}

#include <iostream>

using namespace std;

long long int recur(long long int n);
long long int has(long long int n);

long long int dynamic[10000];

int main(){
    long long int n, ans;

    cin >> n;
    memset(dynamic, -1, 10000);

    ans = recur(n);

    cout << ans + n << endl;

    return 0;
}

long long int recur(long long int n){
    long long int a, b;

    b = has(n);
    if(b == 0){
        return  1;
    }
    if(n < 10000 && dynamic[n] != -1)
        return dynamic[n];
    a = n / b;
    n /= b;
    if(n != 1)
        a += recur(n);
    if(n < 10000)
        dynamic[n] = a;
    return a;

}

long long int has(long long int n){
    if(n % 2 == 0)
        return 2;
    for(long long int i=3; i<n/2 + 1; i += 2)
        if(n % i == 0)
            return i;
    return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int n, sm, i,j;

int mindiv(int x){
    int i;
    for (i=2; i<=sqrt(n)+1; i++ )
        if (x%i==0 ) return i;
    return x;   }

int main() {
    cin>>n;
    sm=n;
    while (n>1) {
        n/=mindiv(n);
        sm+=n;
        }
    cout<<sm+1;
    return 0; }

#include <iostream>

using namespace std;

int main(){
int n;
cin >> n;
int result = n;
while((n % 2 == 0 && n / 2 != 1) || (n % 3 == 0 && n / 3 != 1)){
if(n % 2 == 0){n /= 2;}else if(n % 3 == 0){n /= 3;}
result += n;
}
result += 1;
cout << result << endl;
}

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <cassert>
#include <list>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define REP(i,n) for(int i=0, _n=n; i<_n; i++)
#define FOREACH(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)

using namespace std;
const int INF=1000000000;

const int MAXR=31700; // ~~ sqrt(10^9)
bool isprime[MAXR];
vector<int> primes;
void calcprimes() {
	memset(isprime,1,sizeof(isprime));
	isprime[1]=false;
	for(int i=2; i<MAXR; i++)
		if(isprime[i])
			for(int k=i+i; k<MAXR; k++)
				isprime[k]=false;

	for(int i=2; i<MAXR; i++)
		if(isprime[i]) primes.push_back(i);
}

int main()
{
    ios_base::sync_with_stdio(false);
	long long N;
	cin>>N;
	calcprimes();
	long long sum=N;
	while(N>1) {
		long long div=N;
		FOREACH(p,primes)
			if(N%*p==0) {
				div=*p;
				break;
			}
		N/=div;
		sum+=N;

	}

	cout<<sum<<endl;
}

/***********************************************\
 |Author: WiYR
 |Created Time: 2013/7/18 20:01:18
 |File Name: Rectangular Game.cpp
 |Description:
\***********************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>

using namespace std;
__int64 ans=0;
int main() {
    int n,i;
    cin>>n;
    while(n!=1){
        for(i=2;i*i<n;i++)
            if(n%i==0)
                break;
        if(n%i!=0)
            i=n;
        ans+=n/i;
        n=n/i;
    }
    cout<<ans<<endl;
    return 0;
}

#include <stdio.h>

int n;

int main()
{
    while ( EOF != scanf("%d", &n) )
    {
        int ans= 0;
        while ( n )
        {
            if ( n&1 )
            {
                ans+=n;
                if (n>1)
                    n = 1;
                else
                    n = 0;
            }
            else
            {
                ans+=n;
                n>>=1;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

#include<bits/stdc++.h>

typedef long long ll;
using namespace std;
#define pi 3.1415926536
int func(int n){
    int f;
    f=(int)sqrt(n);
    for(int i=2;i<=f;i++){
        if(n%i==0)
            return n/i;
    }
 return 1;
}

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,ans;
cin>>n;
ans=n;
while(n>1){
    //cout<<ans<<" "<<func(n)<<"\n";
    ans=ans+func(n);
    if(func(n)==1)
        break;
    n=n-func(n);
}
cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n, bagi;
    cin >> n;
    for (int i=2; i<=n; i++){
        if (n%i==0){
            bagi=i;
            break;
        }
    }
    long long jumlah=n;
    while(n%bagi==0){
        jumlah+=n/bagi;
        n/=bagi;
    }
    if (n==1)
        cout << jumlah << endl;
    else
        cout << jumlah+1 << endl;
}

#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long			ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>			vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>			vpii;

const int N = 25;

int main(int argc, char *argv[])
{
#ifndef ONLINE_JUDGE
	freopen(argv[1],"r",stdin);
#endif
#ifndef ONLINE_JUDGE
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ll n;
	cin >> n;
	ll ans = n;
	while (n > 1) {
		if (n%2 == 0) {
			ans += n/2;
			n /= 2;
		} else if (n%3 == 0) {
			ans += n/3;
			n /= 3;
		} else {
			++ans;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 2; i * i < n; ++i) {
    while (n % i == 0) {
      ans += n;
      n /= i;
    }
  }
  ans += n == 1 ? 1:n + 1;
  cout << ans;

  return 0;
}

#include <iostream>
#include <cmath>
using namespace std;

int findHF(int x){
	int HF = 1;
	for (int i = 2; i <= sqrt(x); i++){
		if (x%i == 0) HF = i;
	}
	return HF;
}
int main(){
	int x;
	cin >> x;

	int sum = 0;
	while (x > 1){
		sum += x;
		int HF = findHF(x);
		if (HF != 1) x = x/HF;
		else x = 1;
		cout << x << endl;
	}
	sum++;
	cout << sum;
}

#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <cmath>
#include<cstring>
#include<iomanip>
#include<queue>
#include<functional>
#include<iterator>
#include<istream>
using namespace std;
#define pi 3.141592653589793
#define ii pair<int,int>
#define llll pair<ll,ll>
#define ll long long
#define p10(ans) printf("%0.10f\n", ans);
#define pr(ans) printf("%d\n", ans);
#define scc(x)  scanf(" %c", &c);
#define pll(ans) printf("%lld\n", ans);
#define scll(x) scanf("%lld",&x);
#define sci(x)  scanf("%d",&x);
#define pc(ans)  printf("%c", ans);
#define ps(s)    printf("%s\n", s.c_str());
#define mod 1000000007
#define mem(arr,d) memset(arr,d,sizeof(arr))
#define ninf -10000000000000000;
#define inf 10000000000000000;
/*ll power(ll base, ll exp) {
	base %= mod;
	ll result = 1;
	while (exp > 0) {
		if (exp & 1)
			result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}
*/
/*long long gcd(long long a, long long b)
{
	if (b == 0)return a; return gcd(b, a%b);
}
long long lcm(long long a, long long b) {
	return  a * b / gcd(a, b);
}
*/
/*int arr1[10500];
int arr[110][110];
int main()
{
	int n;
	mem(arr1, 0);
	sci(n);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			sci(arr[i][j]);
			if ((((i + j) & 1) == 0))
			{
				arr1[i - j+n] += arr[i][j];
				arr[i][j] = 0;
			}
		}
	}
	int o = 3 * n;
	ll ans = 0;
	for (int i = 0; i < o; ++i)ans += arr1[i];
	int p = (n - 1) / 2;
	for (int i = 0; i < n; ++i) { ans += arr[p][i]; ans += arr[i][p]; }
	cout << ans << endl;
  return 0;
}

*/
int main()
{
	int n;
	sci(n);
	ll ans = n;
	while ((n & 1) == 0)
	{
		n /= 2;
		ans += n;
	}
	if(n>1)ans += 1;
	cout << ans << endl;
}

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <sstream>

using namespace std;

int main()
{
	int n; cin >> n;
	int res = 1;
	while (n % 2 == 0)
	{
		res += n;
		n /= 2;
	}
	if (n != 1) res += n;
	cout << res << endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <array>
#include <map>
#include <iterator>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <search.h>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <numeric>
#include <bitset>
#include <sstream>
#include <stdio.h>
#include <set>
using namespace std;

//*****************************************************************************************************************************************************************

char letters[27] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
char reversed_letters[27] = { 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a' };
char vowels[13] = { 'A', 'O', 'E', 'Y', 'U', 'I', 'a', 'o', 'y', 'e', 'u', 'i' };

//*****************************************************************************************************************************************************************

long long find_max_vector(vector<long long int> arr) {
    int ans = 0;
    for (int i = 0; i < arr.size(); i++) {
        if (arr[i] > ans) { ans = arr[i]; }
    }
    return ans;
}
long long int factorial(long long  n) {
    return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
}
int gcd(long long a, long long  b)
{
    if (a == 0) { return b; }
    return gcd(b % a, a);
}
int linear_count(int n, vector<int>arr) {
    int ans = 0;
    for (int i = 0; i < arr.size(); i++) { if (arr[i] == n) { ans++; } }
    return ans;
}
long long  find_min_vector(vector<long long int> arr) {
    bool move = true;
    int ans = 0;
    for (int i = 0; i < arr.size(); i++) {
        if (move) { ans = arr[i]; }
        else if (arr[i] < ans) { ans = arr[i]; }
    }
    return ans;
}
bool is_palindrome(string s) {
    string copys = s; reverse(copys.begin(), copys.end()); return copys == s;
}
bool exist(char arr[13], char s) {
    for (int i = 0; i < 12; i++) { if (arr[i] == s) { return true; } }
    return false;
}
bool linear_search_boolean_string(string str, char s) {
    for (int i = 0; i < str.size(); i++) {
        if (str[i] == s) { return true; }
    }
    return false;
}
int sum_vector(vector<int> arr) {
    int ans = 0;
    for (int i = 0; i < arr.size(); i++) {
        ans += arr[i];
    }
    return ans;
}
string lower(string str) {
    for (int i = 0; i < str.size(); i++) { str[i] = tolower(str[i]); } return str;
}
string upper(string str) {
    for (int i = 0; i < str.size(); i++) { str[i] = toupper(str[i]); } return str;
}
long long lcm(long long a, long long b) {
    if (a > b)
        return (a / gcd(a, b)) * b;
    else
        return (b / gcd(a, b)) * a;
}
int digit_to_int(char x) {
    int answer = (int)x - 48;
    return answer;
}
int string_to_int(string s) {
    return stoi(s);
}
bool binarySearchboolean(vector<long long int>arr, int l, int r, int x) {
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return true;
        if (arr[mid] > x)
            return binarySearchboolean(arr, l, mid - 1, x);
        return binarySearchboolean(arr, mid + 1, r, x);
    }return false;
}
vector<long long int> primes;
void sieve(){

    const long long int N = 1000000;
    long long int arr[N + 1] = { 0 };
    arr[0] = 1;
    for (long long int i = 2; i <= N; i++)
    {
        for (long long int j = i * i; j <= N; j += i)
        {
            arr[j - 1] = 1;
        }
    }
    for (long long int i = 1; i <= N; i++)
    {
        if (arr[i - 1] == 0)
        {
            primes.push_back(i);
        }
    }
}
long long int count_combinations(long long int n , long long k) {
    return factorial(n) / (factorial(k) * factorial(n - k));
}
long long int count_permutations(long long int n, long long k) {
    return factorial(n) /  factorial(n - k);
}
long long int count_combinations_with_replacement(long long int n, long long k) {
    return (n + factorial(k - 1)) / (factorial(k) * factorial(n - k));
}

//*****************************************************************************************************************************************************************
#define ll long long
#define cll const long long
#define ci const int
#define pl pair<ll,ll>
#define pi pair < int,int>
#define vi vector<int>
#define vl vector <ll>
#define vpi vector <pair < int , int > >
#define setl set<ll>
#define seti set<int>
#define setc set<char>
#define setstr set<string>
#define db double
#define usetc set<char>
#define usetstr set<string>
#define uset unordered_set <int>
#define usetl unordered_set <ll>
#define chr char

//*****************************************************************************************************************************************************************

int main() {
    pi p = { 0 , 0 };
    ll  k, n, test, ans = 0, pointer = 1000000000,row = 0,col = 0;
    cll N = 0;
    usetl sett;
    setl ss;
    map < ll, ll > frq;
    vl  arr,cs,mod;
    bool move = true;
    string str, s1 = "", s2 = "";
    cin>>n;
    while (n!=1)
    {
        if (n % 2 == 0)
        {
            ans += n;
            n /= 2;
        }
        else
        {
            ans += n;
            ans++; break;
        }
    }
    if (n == 1) { ans++; }
    cout << ans << endl;
    return  0;
}

#include<stdio.h>
#include<vector>
using namespace std;
vector<int> dels;
int main()
{
	long long n;
	scanf("%I64d",&n);
	long long sn=n;
	for(int i=2;i<=1000000;i++)
	{
		while(n%i==0)
		{
			dels.push_back(i);
			n/=i;
		}
	}
	long long sum=sn;
	for(int i=0;i<dels.size();i++)
	{
		sn/=dels[i];
		sum+=sn;

	}
	printf("%I64d\n",sum);
}

#include <vector>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>
#include <iomanip>

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	tr(c,i)	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())

typedef long long			ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>			vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>			vpii;

const int N = 25;

int count(int n)
{
	int ret = 0;
	while (n) {
		n &= (n-1);
		++ret;
	}
	return ret;
}

int main(int argc, char *argv[])
{
#ifndef ONLINE_JUDGE
	freopen(argv[1],"r",stdin);
#endif
#ifndef ONLINE_JUDGE
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ll n;
	cin >> n;
	if (n&1) {
		cout << n+1 << endl;
		return 0;
	}
	ll ans = n;
	if (count(n) == 1) {
		while (n > 1) {
			n >>= 1;
			ans += n;
		}
	} else {
		while (!(n&1)) {
			ans += n/2;
			n /= 2;
		}
		++ans;
	}
	cout << ans << endl;
	return 0;
}

#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<memory.h>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<sstream>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(),(a).end()
const long long INF=1000000000000;
const int MOD=1000000007;
const double EPS=1e-9;
const double PI=acos(-1.0);
long long s,n,q,p,i;
bool ok(long long x){
	return x>1;
}
int main(){
	cin>>n;
	s=n;
	while(n>=1){
		q=INF;
		for(i=1;i*i<=n;i++)
			if(n%i==0){
				if(ok(i))q=min(q,i);
				if(n/i!=i){
					if(ok(n/i))q=min(q,n/i);
				}
			};
		if(q==n)break;
		p=n/q;
		s+=n-p;
		n-=p;
	}
	cout<<s+1<<endl;
}

#include<iostream>
#include<math.h>
#include<vector>
using namespace std;
int main ()
{
	int n;
	cin>>n;
	int sum = n;
	while (n%2==0)
	{
		n/=2;
        sum+=n;
	}
	sum++;
    cout<<sum;
	return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <list>
#include <random>
#include <queue>
#include <stdio.h>
#include <regex>
#include <bitset>
#include <numeric>
#include <bitset>
#include <assert.h>
#include <conio.h>
#include <sstream>
#include <fstream>
#include <cstring>

using namespace std;

#define forn(i, k) for (int64 i = 0; i < int64(k); i++)
#define nfor(i, k) for (int64 i = int64(k) - 1; i >= 0; i--)
#define fore(i, l, r) for (int64 i = int64(l); i < int64(r); i++)
#define all(cd) (cd).begin(), (cd).end()
#define mp(x, y) make_pair((x), (y))
#define sqr(cd) ((cd) * (cd))

template <typename T> void alert(const T& t) { cout << t; exit(0); }

typedef long long int64;
typedef unsigned long long uint64;
typedef vector<int> vint;
typedef vector<bool> vbool;
typedef vector<int64> vint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;

int64 xD(int64 n)
{
	if (n == 1) return 0;

	for (int64 i = sqrt(n); i >= 2; --i)
	{
		if (n % i == 0) return max(i,n/i);
	}

	return 1;
}

int main()
{
#ifdef _DEBUG
	freopen("ReadMe.txt", "r", stdin);
	//freopen("123.txt", "w", stdout);
	//test();
#else
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("123.txt", "w", stdout);
}
#endif
//srand(time(NULL));

	int64 n;
	cin >> n;

	int64 sum = 0;
	sum += n;

	while (n)
	{
		n = xD(n);
		sum += n;
	}

	cout << sum;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,b,q;

    cin>>n;
    long long total=n;

    for(int i=2;i<=ceil(sqrt(n));i++)
    {
        if(n%i==0)
        {n=n/i;
            total=total+n;
        }
    }

    cout<<total+1;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <regex>
#include <bitset>
#include <cstdio>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
typedef long double double64;
typedef vector<int64> VI;
typedef pair<int64, int64> PII;

template <typename T> void alert(const T& t) { cout << t; exit(0); }
template<typename T> inline void alert(vector<T> &t, char delim = ' ') { for (T const& ti : t) cout << ti << delim; exit(0); }

#define mp make_pair
#define rep(i,start,lim) for(int64 i = start;i< lim; i++)
#define forn(i, n) for (int64 i = 0; i < int64(n); i++)
#define nfor(i, n) for (int64 i = int64(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int64 i = int64(l); i < int64(r); i++)
#define efor(i, l, r) for (int64 i = int64(l) - 1; i >= int64(r); i--)
#define all(a) (a).begin(), (a).end()
#define mp(x, y) make_pair((x), (y))
#define sqr(a) ((a) * (a))
#define stodigit(a) (a - '0')
#define chtodigit(a) (a - 'a')

const int64 MAX64 = 1 + 1e+18;
const int  MAX = 1 + 1e+9;
const double PI = 3.1415926536;
const int64 CEL = 26;
int64 MID(int64 l, int64 r) { return (l + r) / 2; }
int64 LSON(int64 u) { return u * 2; }
int64 RSON(int64 u) { return u * 2 + 1; }

/*----------------------------------------------------------*/
/*
typedef vector<int64> Edges_t;

struct Node
{
	Node() : color('w') {}
	char color;
	Edges_t edges;
};

typedef vector<Node>  Graph_t;

Graph_t graph;

int64 answer = 0;

int64 DFS(int64 start, int64 cnt)
{
    forn(i, graph[start].edges.size())
    {
        int64 u = graph[start].edges[i];

        DFS(u, cnt + 1);
    }

    answer = max(answer, cnt);
}
*/

/*----------------------------------------------------------*/

struct Point
{
	Point() : x(0), y(0) {};
	Point(double X, double Y) : x(X), y(Y) {};

	double x;
	double y;
};

int64 GCD(int64 a, int64 b)
{
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int64 LCM(int64 a, int64 b)
{
	return (a * b) / GCD(a, b);
}

size_t version2(int64 n) {
	size_t result = 0;
	while (n) {
		n &= n - 1;
		result++;
	}
	return result;
}

// степень двойки if ((i & (i - 1)) == 0)
// ceil(); - вверх floor(n + 0.5); - вниз

#define TASKNAME "lepus"

int main()
{
#ifdef _DEBUG
	freopen("ReadMe.txt", "r", stdin);
#else
{
	//freopen(TASKNAME".in", "r", stdin);
	//freopen(TASKNAME".out", "w", stdout);
}
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(0);

    int64 n; cin >> n;
    int64 answer = 0;

    while(n % 2 == 0)
    {
        answer += n;
        n /= 2;
    }
    while(n % 3 == 0)
    {
        answer += n;
        n /= 3;
    }

    if(n != 1) answer += n + 1;
    else answer += 1;

    alert(answer);

    return 0;
}

#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<memory.h>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<sstream>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(),(a).end()
const long long INF=1000000000000;
const int MOD=1000000007;
const double EPS=1e-9;
const double PI=acos(-1.0);
long long s,n,q,p,i;
bool ok(long long x){
	return x!=1&&x!=n;
}
int main(){
	cin>>n;
	s=n;
	while(n>1){
		p=0;
		q=INF;
		for(i=1;i*i<=n;i++)
			if(n%i==0){
				if(ok(i)&&ok(n/i))q=min(q,i),p=max(p,n/i);
				if(n/i!=i){
					if(ok(n/i)&&ok(n/(n/i)))q=min(q,n/i),p=max(p,n/(n/i));
				}
			};
		if(q>p)swap(q,p);
		if(p==INF){s++; break;}
		s+=p;
		q--;
		n=q*p;
	}
	cout<<s<<endl;
}