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.

import java.io.*;
import java.util.*;
import java.math.*;

//4/22/12 1:15 AM
//by Abrackadabra

public class B1 {
    public static void main(String[] args) throws IOException {
        if (args.length > 0 && args[0].equals("Abra")) debugMode = true;
        new B1().run();
        /*new Thread(null, new Runnable() {
            public void run() {
                try {
                    new B1().run();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 24).start();*/
    }

    int IOMode = 0; //0 - consoleIO, 1 - <taskName>.in/out, 2 - input.txt/output.txt, 3 - test case generator
    String taskName = "";

    void solve() throws IOException {
        int n = nextInt();
        int res = n + 1;
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                n /= i;
                res += n;
                i = 1;
                continue;
            }
        }
        out.println(res);
    }

    long startTime = System.nanoTime(), tempTime = startTime, finishTime = startTime;
    long startMem = Runtime.getRuntime().totalMemory(), finishMem = startMem;

    void run() throws IOException {
        init();
        if (debugMode) {
            con.println("Start");
            con.println("Console:");
        }
        solve();
        finishTime = System.nanoTime();
        finishMem = Runtime.getRuntime().totalMemory();
        out.flush();
        if (debugMode) {
            int maxSymbols = 1000;
            BufferedReader tbr = new BufferedReader(new FileReader("input.txt"));
            char[] a = new char[maxSymbols];
            tbr.read(a);
            if (a[0] != 0) {
                con.println("File input:");
                con.println(a);
                if (a[maxSymbols - 1] != 0) con.println("...");
            }
            tbr = new BufferedReader(new FileReader("output.txt"));
            a = new char[maxSymbols];
            tbr.read(a);
            if (a[0] != 0) {
                con.println("File output:");
                con.println(a);
                if (a[maxSymbols - 1] != 0) con.println("...");
            }
            con.println("Execution time: " + (finishTime - startTime) / 1000000000.0 + " sec");
            con.println("Used memory:    " + (finishMem - startMem) + " bytes");
            con.println("Total memory:   " + Runtime.getRuntime().totalMemory() + " bytes");
        }
    }

    boolean tick(double x) {
        if (System.nanoTime() - tempTime > x * 1e9) {
            tempTime = System.nanoTime();
            con.println("Tick at " + (tempTime - startTime) / 1000000000 + " sec");
            con.print("   ");
            return true;
        }
        return false;
    }

    static boolean debugMode = false;
    PrintStream con = System.out;

    void init() throws IOException {
        if (debugMode && IOMode != 3) {
            br = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter(new FileWriter("output.txt"));
        } else
            switch (IOMode) {
                case 0:
                    br = new BufferedReader(new InputStreamReader(System.in));
                    out = new PrintWriter(System.out);
                    break;
                case 1:
                    br = new BufferedReader(new FileReader(taskName + ".in"));
                    out = new PrintWriter(new FileWriter(taskName + ".out"));
                    break;
                case 2:
                    br = new BufferedReader(new FileReader("input.txt"));
                    out = new PrintWriter(new FileWriter("output.txt"));
                    break;
                case 3:
                    out = new PrintWriter(new FileWriter("input.txt"));
                    break;
            }
    }

    BufferedReader br;
    PrintWriter out;
    StringTokenizer in;

    boolean hasMoreTokens() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) return false;
            in = new StringTokenizer(line);
        }
        return true;
    }

    String nextString() throws IOException {
        return hasMoreTokens() ? in.nextToken() : null;
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}

import java.util.Scanner;
import java.lang.Math;
public class rectangulargame{
	static int divchecker(int n){
		for(int i=2;i<=Math.sqrt(n);i++){
			if(n%i==0)
				return (int)n/i;
		}
		return 1;
	}
	public static void main(String args[]){
		Scanner input= new Scanner(System.in);
		int n=input.nextInt();
		int ans=n;
		while(n>1){
				n=divchecker(n);
				ans+=n;
			}
		System.out.println(ans);
	}
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class ABYB{
    static BufferedReader br;
    public static void main(String args[])throws Exception{
        br=new BufferedReader(new InputStreamReader(System.in));
        long n=toLong();
        if(isPrime(n)){
            System.out.println(n+1);
            return;
        }
        long count=n;
        while(n>1){
            if(isPrime(n)){
                count++;
                break;
            }
            long root=(long)Math.sqrt(n)+1;
            for(int i=2;i<=root;i++){
                if(n%i==0){
                    n=n/i;
                    count+=n;
                    break;
                }
            }
        }
        System.out.println(count);

    }
    public static boolean isPrime(long x) {
        BigInteger bi = new BigInteger(x + "");
        return bi.isProbablePrime(10);
    }

    /****************************************************************/
    public static int[] toIntArray()throws Exception{
       String str[]=br.readLine().split(" ");
       int k[]=new int[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Integer.parseInt(str[i]);
       }
       return k;
    }
    public static int toInt()throws Exception{
       return Integer.parseInt(br.readLine());
    }
    public static long[] toLongArray()throws Exception{
       String str[]=br.readLine().split(" ");
       long k[]=new long[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Long.parseLong(str[i]);
       }
       return k;
    }
    public static long toLong()throws Exception{
       return Long.parseLong(br.readLine());
    }
    public static double[] toDoubleArray()throws Exception{
       String str[]=br.readLine().split(" ");
       double k[]=new double[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Double.parseDouble(str[i]);
       }
       return k;
    }
    public static double toDouble()throws Exception{
       return Double.parseDouble(br.readLine());
    }
    public static String toStr()throws Exception{
       return br.readLine();
    }
    public static String[] toStrArray()throws Exception{
       String str[]=br.readLine().split(" ");
       return str;
    }
    /****************************************************************/

}

import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        OutputStream output = System.out;
        PrintWriter pr = new PrintWriter(output);
        int n = sc.nextInt();

        long sum = 0;
        boolean check = false;
        for (int i = 2 ; i <= Math.sqrt(n) ; i ++) {
            if (n % i == 0) {
                sum += (long) n;
                n = n / i;
                i = 1;
            }

            if (n == 1) {
                check = true;
                break;
            }
        }

        if (check == false) {
            sum += (long) n;
        }
        pr.println(sum + 1);
        pr.close();
    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class P177B {

  public PrintWriter run() {
    int n = sc.nextInt();
    int sum = n;

    while (n > 2) {
      int bm = (int)Math.sqrt((double)n);
      int a = 1;
      int b = 1;
      for (b = 2; b <= bm; b++) {
        if (n % b == 0) {
          a = n / b;
          break;
        }
      }
      if (a == 1 || b == 1) {
        break;
      }

      n = Math.max(a, b);
      sum += n;
    }
    sum++;

    pw.println(sum);

    return pw;
  }

  private Scanner sc = new Scanner(new BufferedInputStream(System.in));
  private PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

  public static void main(String... args) throws Exception {
    new P177B().run().close();
  }

}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer input = sc.nextInt();
        System.out.println(playGame(input));
    }
    private static int playGame(int currentInput){
        if(currentInput == 1){
            return 1;
        }
        int divisor = 2;
        while(currentInput % divisor != 0){
            divisor++;
        }
        return currentInput + playGame(currentInput / divisor);
    }
}

import java.util.*;
import java.io.*;

public class ProblemC {
	Scanner sc = new Scanner(System.in);
	PrintStream out = System.out;

	void start() {
		int n = sc.nextInt();
		int ans = n;

		while (n >= 2) {
			boolean ok = false;
			for (int i = 2; i <= Math.sqrt(n); i++) {
				if (n % i == 0) {
					ans += n / i;
					n =	n / i;
					ok = true;
					break;
				}
			}
			if (!ok) {
				ans += 1;
				n = 1;
				break;
			}

		}

		out.println (ans);

	}

	public static void main(String[] args) {
		new ProblemC().start();
	}

}

/**
 * Write a description of class ABBYYB here.
 *
 * @author (your name)
 * @version (a version number or a date)
 */
import java.util.*;
public class ABBYYB
{
    public static int GF(int n)
    {
        for(int i = 2; i < n; i++)
        {
            if(n % i == 0)
                return (n/i);
        }
        return 1;
    }
    public static void main(String args[])
    {
        Scanner S = new Scanner(System.in);
        int n = S.nextInt();
        int x = n;
        int sum = n;
        while(x != 1)
        {
            x = GF(x);
            sum += x;
        }
        System.out.println(sum);
    }

}

// package codeforces.practice;

/**
 *
 * @author Abhishek Shankhadhar
 */
import java.io.*;
import java.util.*;
public class AbbyyCupB2 {

    InputStream obj;
    PrintWriter out;
    String check = "";

    //Solution !!

    void solution() {
        int n=inti();
        long sum=0;
        while (true) {
            sum+=n;
            n=solve(n);
            if(n==-1)
                break;
        }
        sum+=1;
        out.println(sum);
    }

    int solve(int n){
        for(int i=2;i*i<=n;i++){
            if(n%i==0){
                return Math.max(i, n/i);
            }
        }
        return -1;
    }

    //------->ends !!

    public static void main(String[] args) throws IOException {
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    new AbbyyCupB2().ace();
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (StackOverflowError e) {
                    System.out.println("RTE");
                }
            }
        }, "1", 1 << 26).start();
    }

    void ace() throws IOException {
        out = new PrintWriter(System.out);
        obj = check.isEmpty() ? System.in : new ByteArrayInputStream(check.getBytes());
//        obj=check.isEmpty() ? new FileInputStream("location of file") : new ByteArrayInputStream(check.getBytes());
//        long t1=System.currentTimeMillis();
        solution();
//        long t2=System.currentTimeMillis();
//        out.println(t2-t1);
        out.flush();
        out.close();
    }
    byte inbuffer[] = new byte[1024];
    int lenbuffer = 0, ptrbuffer = 0;

    int readByte() {
        if (lenbuffer == -1) {
            throw new InputMismatchException();
        }
        if (ptrbuffer >= lenbuffer) {
            ptrbuffer = 0;
            try {
                lenbuffer = obj.read(inbuffer);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }
        if (lenbuffer <= 0) {
            return -1;
        }
        return inbuffer[ptrbuffer++];
    }

    boolean isSpaceChar(int c) {
        return (!(c >= 33 && c <= 126));
    }

    String stri() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
        {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b));
        return b;
    }

    int inti() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    long loni() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    float fl() {
        return Float.parseFloat(stri());
    }

    double dou() {
        return Double.parseDouble(stri());
    }

    char chi() {
        return (char) skip();
    }

    int[] arri(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = inti();
        }
        return a;
    }

    long[] arrl(int n) {
        long a[] = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = loni();
        }
        return a;
    }

    String[] stra(int n) {
        String a[] = new String[n];
        for (int i = 0; i < n; i++) {
            a[i] = stri();
        }
        return a;
    }

    private static void pa(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
//    uwi mod pow function

    public static long pow(long a, long n, long mod) {
//		a %= mod;
        long ret = 1;
        int x = 63 - Long.numberOfLeadingZeros(n);
        for (; x >= 0; x--) {
            ret = ret * ret % mod;
            if (n << 63 - x < 0) {
                ret = ret * a % mod;
            }
        }
        return ret;
    }

    int gcd(int a, int b) {
        if (a == 0) {
            return b;
        }
        return gcd(b % a, a);
    }
    long lcm(int a, int b) {
        return a * (b / gcd(a, b));
    }
}

import java.io.PrintWriter;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author admin
 */
public class P177B1 {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int c = n;
        for(int i = 2; i <= Math.sqrt(n); ++i)
        {
            while(n % i == 0)
            {
                n = n / i;
                c = c + n;
            }
        }
        if(n > 1)
            c++;
        out.print(c);
        out.close();
    }
}

import java.util.*;
import java.io.*;
public class Main{
public static void main(String... args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] temp = br.readLine().split(" ");
int n = Integer.parseInt(temp[0]);
int[] t = new int[n+1];
t[1]=1;
for (int i=2; i<=n; i++){
  int max = 0;
  for (int j=1; j<i; j++){
    if (i%j==0) max = Math.max(max,t[j]);
  }
  t[i]=i+max;
}
System.out.println(t[n]);
}
}

import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        solve(n,n);
    }

    public static void solve(long n, long sum) {
        if (n == 1) {
            System.out.println(sum);
            System.exit(0);
        }
        if (n % 2 == 0)
            solve(n / 2, sum + n / 2);
        else {
            for (int i = 3; i < n / 2; i += 2) {
                if (n % i == 0)
                    solve(n / i, sum + n / i);
            }
            solve(1, sum+1);
        }
    }

}

import java.util.*;

public class CodeForces177B2{
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		//ArrayList<Integer> arr = new ArrayList<>();
		int ans = n;
		for(int i = 2;i<=Math.sqrt(n);i++){
			while(n%i == 0){
				ans+= n/i;
				n/= i;
			}
		}
		if(n > 1){
			ans+= n/n;
		}
		System.out.println(ans);
	}
}

import java.util.Scanner;
public class Ishu
{
	public static void main(String[] args)
	{
	Scanner scan=new Scanner(System.in);
	int n,i,sum;
	boolean flag=true;
	n=scan.nextInt();
	sum=n;
	while(n>1)
		{
		flag=true;
		for(i=2;i<=Math.sqrt(n);++i)
			{
			if(n%i==0)
				{
				n=n/i;
				sum+=n;
				flag=false;
				break;
				}
			}
		if(flag)
			{
			n=1;
			sum+=n;
			}
		}
	System.out.println(sum);
	}
}

import static java.util.Arrays.deepToString;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws IOException {
        int n = nextInt();
        long max = n;
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                max += n / i;
                n = n / i;
                i--;
            }
        }
        max = max + 1;
        System.out.println(max);
    }

    public static void main(String[] args) throws Exception {
        reader = new BufferedReader(new InputStreamReader(System.in));
        writer = new PrintWriter(System.out);

        setTime();
        solve();
        printTime();
        printMemory();

        writer.close();
    }

    static BufferedReader reader;
    static PrintWriter writer;
    static StringTokenizer tok = new StringTokenizer("");
    static long systemTime;

    static void debug(Object... o) {
        System.err.println(deepToString(o));
    }

    static void setTime() {
        systemTime = System.currentTimeMillis();
    }

    static void printTime() {
        System.err.println("Time consumed: "
                + (System.currentTimeMillis() - systemTime));
    }

    static void printMemory() {
        System.err.println("Memory consumed: "
                + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime()
                        .freeMemory()) / 1000 + "kb");
    }

    static String next() {
        while (!tok.hasMoreTokens()) {
            String w = null;
            try {
                w = reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (w == null)
                return null;
            tok = new StringTokenizer(w);
        }
        return tok.nextToken();
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static long nextLong() {
        return Long.parseLong(next());
    }

    static double nextDouble() {
        return Double.parseDouble(next());
    }

    static BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class CF177B1{
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        List<Integer> prime = new ArrayList<>();
        prime.add(2);
        prime.add(3);
        prime.add(5);
        for (int x=7; x*x<1000000000; x++){
            boolean isP = true;
            for (int now : prime){
                if (x%now == 0){
                    isP = false;
                    break;
                }
                if (now*now>x)
                    break;
            }
            if (isP)
                prime.add(x);
        }
        while (scn.hasNext()){
            int n = scn.nextInt();
            int ans = n;
            for (int now : prime){
                while (n%now == 0){
                    n /= now;
                    ans += n;
                }
                if (n==1) break;
                if (now*now>n){
                    ans ++;
                    break;
                }
            }
            System.out.println(ans);
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class A {
	static TreeMap<Integer, Integer> map;

	static int backtrack(int n)
	{
		if(n == 1)
			return 1;
		if(map.get(n) != null)
			return map.get(n);
		int ans = 0;
		for(int i=2;i*i<=n;i++)
			if(n%i == 0)
			{
				ans = Math.max(ans, n + backtrack(n/i));
				ans = Math.max(ans, n + backtrack(i));
			}
		ans = Math.max(ans, n + backtrack(1));
		map.put(n, ans);
		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		map = new TreeMap<>();
		System.out.println(backtrack(n));
	}

	static class Scanner{
		StringTokenizer st;BufferedReader br;
		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public String next() throws IOException
		{while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());return st.nextToken();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public boolean ready() throws IOException {return br.ready();}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 *
 * @author juacar01
 */
public class RectangularGame_177B1 {

        /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        MyScanner sc = new MyScanner();
        long num =0;
        num = sc.nextInt();
        long div=2, total=1;
        while(num>1){
            if (div*div>num) {
                total+=num;
                break;
            }
            else{
                if (num%div==0) {
                    total+=num;
                    num/=div;
                }
                else{
                    div++;
                }
            }

        }
        System.out.println(""+total);

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {

        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------

}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author hheng
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB1 solver = new TaskB1();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB1 {
    int n;

	public void solve(int testNumber, Scanner in, PrintWriter out) {
        n = in.nextInt();
        out.println(doit(n));
	}

    public int doit(int n) {
        //System.out.println(n);
        if (n==1) return 1;
        //if (memo[n] != -1) return memo[n];

        int res = 1;
        int rem = 1;
        for (int i=2; i<=Math.sqrt(n); i++) {
            if (n%i == 0) {
                if (res < n/i) { res = n/i; rem = n/i; }
                if (res < i) { res = i; rem = i; }
            }
        }
        res = n + doit(rem);
        return res;
    }

}

import java.util.Arrays;
import java.util.Scanner;

public class Prob177B2 {
	static boolean[] isPrime;
	static int[] primes;
	static int[] smallestPrime;

	public static void main(String[] Args) {
		// mark primes
		smallestPrime = new int[100000];
		isPrime = new boolean[100000];
		primes = new int[9592];

		Arrays.fill(isPrime, true);
		Arrays.fill(smallestPrime, 1);

		isPrime[0] = false;
		isPrime[1] = false;

		int count = 0;
		for (int i = 2; i < isPrime.length; i++)
			if (isPrime[i]) {
				primes[count++] = i;
				smallestPrime[i] = i;
				for (int j = 2; i * j < isPrime.length; j++) {
					if (isPrime[i * j]) {
						smallestPrime[i * j] = i;
						isPrime[i * j] = false;
					}
				}
			}

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();

		System.out.println(f(x, 0));
	}

	public static boolean isPrime(long x) {
		if (x < isPrime.length)
			return isPrime[(int) x];
		for (int i = 0; i < Math.sqrt(x) + 1; i++)
			if (isPrime[i] && x % i == 0)
				return false;
		return true;
	}

	public static int f(int x, int sum) {
		if (isPrime(x))
			return sum + x + 1;
		if (x < smallestPrime.length) {
			int answer = 0;
			while (smallestPrime[x] != 1) {
				answer += x;
				x /= smallestPrime[x];
			}
			return sum + answer + 1;
		} else {
			for (int i = 0; i < primes.length; i++)
				if (x % primes[i] == 0)
					return f(x / primes[i], x + sum);
		}
		return 0;
	}
}

import java.util.Scanner;

import static java.lang.Math.sqrt;

public class B1 {
    public static void main(String[] argv) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long result = n;
        int nSqrt = (int) sqrt(n) + 1;
        int i = 2;
        while (i <= nSqrt && n > 1) {
            if (n % i == 0) {
                n = n / i;
                result += n;
            } else {
                i++;
            }
        }
        if (n > 1) {
            ++result;
        }
        System.out.println(result);
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author grolegor
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB1 solver = new TaskB1();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int c = n;
            while (n != 1) {
                int a = divisor(n);
                int b = n / a;
                c += b;
                n = b;
            }
            out.println(c);
        }

        public int divisor(int x) {
            int ans = -1;
            int sqrt = (int) Math.sqrt(x);
            for (int i = 2; i <= sqrt; i++) {
                if (x % i == 0) {
                    ans = i;
                    break;
                }
            }
            if (ans == -1) return x;
            return ans;
        }

    }
}

import java.io.*;
import java.util.*;

public class test2
{

	public static void main(String[] args) throws Exception
	{
		new test2().run();
	}

	PrintWriter out = null;
	int[] dp = null;

	int play(int n)
	{
		if (n == 1)
			return 1;

		if (dp[n] > 0)
			return dp[n];

		int max = 0;
		for (int i = 2; i <= n; i++)
		{
			if (n % i == 0)
				max = Math.max(max, play(n / i));
		}

		dp[n] = n + max;
		return dp[n];
	}

	void run() throws Exception
	{
		Scanner in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		int n = in.nextInt();
		dp = new int[n + 1];

		out.println(play(n));
		out.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Solution {
    public static int maxPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0)
                return n / i;
        }

        return 1;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer token = new StringTokenizer(reader.readLine());

        int n = Integer.parseInt(token.nextToken());
        int s = n;
        while (n != 1) {
            int p = maxPrime(n);
            s += p;
            n = p;
        }

        System.out.println(s);
    }
}

import java.util.Scanner;

public class RectangularGame {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String st = in.nextLine();

		long a = Long.parseLong(st);
		long b=a/2;
		long c = a;
		while (b!=1)
		{
			if(a%b == 0)
			{
				c+=b;
				a=b;
				b=a/2;
			}
			else
				b--;
		}

		System.out.print(++c);

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class B implements Runnable {

	private void Solution() throws IOException {
		int n = nextInt(), ans = n;
		while (n != 1) {
			int del = 1;
			for (int i = 2; i * i <= n; i++)
				if (n % i == 0) {
					del = n / i;
					break;
				}
			ans += del;
			n = del;
		}
		print(ans);
	}

	public static void main(String[] args) {
		new B().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	void print(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(o[i]);
		}
	}

	void println(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				print(" ");
			print(o[i]);
		}
		print("\n");
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(next());
	}

	String nextLine() throws IOException {
		return in.readLine();
	}

	String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}
}

import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int N = n;
		ArrayList<Integer> a = new ArrayList<Integer>();
		int i = 2;
		int t = (int)Math.sqrt(n);
		while(i<=t){
			if(n%i==0){
			a.add(i);
			n/=i;
			}
			else{
			i++;
			}
			t=(int)Math.sqrt(n);
		}
		a.add(n);
		int ans=N;
		for(i=0;i<a.size();i++){
			int x = a.get(i);
			ans+=(N)/x;
			N/=x;
		}
		System.out.println(ans);
	}
}

import java.util.*;
public class Main {
    private static Scanner sc = new Scanner(System.in);

    public static int gcd(int a, int b) {
        if(a == 0) {
            return b;
        }
        return gcd(b % a, a);
    }
    public static void main(String[] args) {
        int n = sc.nextInt();
        int ans = n;
        while(n > 0) {
            boolean flag = false;
            for(int i = 2; i * i <= n; ++i) {
                if(n % i == 0) {
                    ans += n/i;
                    n /= i;
                    flag = true;
                    break;
                }
            }
            if(!flag) {
                ans += 1;
                break;
            }
        }
        System.out.println(ans);

    }
}

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();int count =n;
        while(n>1){
            for(int i=2;i<=n/2+1;i++){
                if(n%i==0){
                    n=n/i;
                    count+=n;
                    break;
                }else if(i==n/2+1 || n==i){
                    n=1;
                    count+=1;
                    break;
                }
            }
        }
        System.out.println(count);
    }

}

import java.util.*;
public class ABA {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =  sc.nextInt();
		System.out.println(magic(N));

	}

	private static long magic(int n) {
		//System.out.println(n);
		for(int a=2;a<=Math.sqrt(n);a++){
			if(n%a==0){
				return n+magic(n/a);
			}
		}
		return n+1;
	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class CodeForces {

	public static void main(String[] args) throws IOException,NumberFormatException{
		try {
			FastScanner sc=new FastScanner();
			int n=sc.nextInt();
			int ans=n;
			while(true) {
				int factor=1;
				for(int i=2;i*i<=n;i++) {
					if(n%i==0) {
						factor=Math.max(n/i, i);
						n=n/i;
						break;
					}
				}
				if(factor==1) {
					ans+=1;
					break;
				}
				ans+=factor;
			}
			System.out.println(ans);

		}
		catch(Exception e) {
			return ;
		}

	}
	public static boolean isPrime(long n) {
		if(n==1)
			return false;
		for(int i=2;i*i<=n;i++) {
			if(n%i==0)
				return false;
		}
		return true;
	}
	public static int[] gcd(int a,int b) {
		if(b==0) {
			return new int[] {a,1,0};
		}
		int[] vals=gcd(b,a%b);
		int d=vals[0];
		int x=vals[2];
		int y=vals[1]-(a/b)*vals[2];
		return new int[] {d,x,y};

	}
	public static long prodDigit(long n) {
		int sum=1;
		while(n!=0) {
			sum*=(n%10);
			n/=10;
		}
		return sum;
	}
	public static int GCD(int a,int b) {
		if(b==0)
			return a;
		return GCD(b,a%b);
	}
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
                                      st=new StringTokenizer(br.readLine());
                              } catch (IOException e) {}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}

	}
}

//package com.example.programmingpractice;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class CodeforcesNT {

    public static void main (String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = br.readLine().trim().split(" ");
        int n = Integer.parseInt(inputs[0]);
        long sum = n;
        for(int i = 2; i*i<=n; i++) {
            while(n%i == 0) {
                sum += n/i;
                n/=i;
            }
        }
        System.out.println(n == 1 ? sum:sum+1);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main
{
  static BufferedReader reader;
  static StringTokenizer tokenizer;
  static PrintWriter writer;

  static int nextInt() throws IOException
  {
    return Integer.parseInt(nextToken());
  }

  static long nextLong() throws IOException
  {
    return Long.parseLong(nextToken());
  }

  static double nextDouble() throws IOException
  {
    return Double.parseDouble(nextToken());
  }

  static boolean eof = false;

  static String nextToken() throws IOException
  {
    while (tokenizer == null || !tokenizer.hasMoreTokens())
    {
      tokenizer = new StringTokenizer(reader.readLine());
    }
    return tokenizer.nextToken();
  }

  public static void main(String[] args) throws IOException
  {
    tokenizer = null;
    reader = new BufferedReader(new InputStreamReader(System.in));
    writer = new PrintWriter(System.out);
    banana();
    reader.close();
    writer.close();
  }

  static void banana() throws IOException
  {
    long n = nextLong();

    int m = 100000;
    boolean prime[] = new boolean[m];
    Arrays.fill(prime, true);
    prime[1] = false;

    for (int i = 2; i < m; ++i)
      if (prime[i])
        for (int j = i + i; j < m; j += i)
          prime[j] = false;

    List<Integer> primes = new ArrayList<Integer>();

    for (int i = 2; i < m; ++i)
      if (prime[i])
        primes.add(i);

    int index = 0;
    long score = n;
    while (n != 1 && index < primes.size())
    {
      while (n % primes.get(index) == 0)
      {
        n /= primes.get(index);
        score += n;
      }
      ++index;
    }
    if (n != 1)
      score++;

    System.out.println(score);

  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class RectangularGame {
	public static void main(String[] args) {
		PrintWriter pw = new PrintWriter(System.out);
	    reader(System.in);
	    int n = nI();
	    int sum = n;
	    while (n != 1) {
	    	n = div(n);
	    	sum += n;
	    }
	    pw.println(sum);
	    pw.close();
	}

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

	private static BufferedReader br;
	private static StringTokenizer st;

	static void reader(InputStream stream) {
	    try {
	        br = new BufferedReader(new InputStreamReader(stream));
	    } catch (Exception e) {
	        e.printStackTrace();
	    }
	}

	static String n() {
	    while (st == null || !st.hasMoreTokens()) {
	        try {
	            st = new StringTokenizer(br.readLine());
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	    }
	    return st.nextToken();
	}

	static int nI() {
	    return Integer.parseInt(n());
	}

	static long nL() {
	    return Long.parseLong(n());
	}
}

import java.util.*;
import java.math.*;

public class S{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int res = n;
        for(long i = 2; i <= n ; i++){
            if(n == 1){
                break;
            }
            while(n % i == 0){
                res += n / i;
                n /= i;
            }
        }
        System.out.print(res);
     }
 }

import java.io.*;

import java.util.*;

public class CodeForces {

	public void solve() throws IOException {
		int n = nextInt();
		int sum = n;

		while(n>1){
			int  a =2;
			while(n%a!=0){
				a++;
			}
			n=n/a;
			sum+=n;
		}

		out.print(sum);

	}

	public static void main(String[] args) {
		new CodeForces().run();
	}

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter(new BufferedWriter(new FileWriter(
						"output.txt")));
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;
			// long t=new Date().getTime();
			solve();
			// writer.println(t-new Date().getTime());
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

import java.io.*;
import java.util.*;

public class RectangularGame {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(f.readLine());
        int sum = n;
        while (n > 1)
        {
            int min = -1;
            for (int i = 2; i*i <= n; i++)
                if (n % i == 0)
                {
                    min = i;
                    break;
                }
            if (min == -1)
                min = n;
            n /= min;
            sum += n;
        }
        System.out.println(sum);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class B1 {

    public static void main(String[] args) throws IOException {
        BufferedReader std = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(std.readLine());
        int sum = n;
        while (n > 1) {
            int d = minDiv(n);
            sum += (n / d);
            n /= d;
        }
        out.println(sum);
        out.flush();
    }

    public static int minDiv(int n) {
        int x = 2;
        while (true) {
            if (n % x == 0  )
                return x;
            x++;
        }
    }
}

import java.util.Scanner;
public class B1177 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int c=n;
        while(n!=1){
        for(int i=2;i<=n;i++)
        {
        if(n%i==0)
           {
            n/=i;
            c+=n;
            break;

           }
        }
        }
        System.out.println(""+c);
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class B177 {

    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

    static int nextInt() throws Exception {
        in.nextToken();
        return (int)in.nval;
    }

    static String nextString() throws Exception {
        in.nextToken();
        return in.sval;
    }

    public static void main(String[] args) throws Exception {
        int x = nextInt();
        long ans = 1;
        for (int d = 2; d*d <= x; d++) {
            while (x%d == 0) {
                ans += x;
                x /= d;
            }
        }
        if (x > 1) ans += x;
        out.println(ans);
        out.flush();
    }

}

import java.io.*;
import java.util.*;

public class test2
{

	public static void main(String[] args) throws Exception
	{
		new test2().run();
	}

	PrintWriter out = null;

	int find(int n)
	{
		int q = (int) Math.sqrt(n);
		for (int i = 2; i <= q; i++)
			if (n % i == 0)
				return n / i;

		return 1;
	}

	int play(int n)
	{
		if (n == 1)
			return 1;

		return n + play(find(n));
	}

	void run() throws Exception
	{
		Scanner in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		int n = in.nextInt();

		out.println(play(n));
		out.close();
	}
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int m=sc.nextInt();
	    int ans=m;
	    while(!prime(m)){
	        int fac=factor(m);
	        ans+=m/fac;
	        m/=fac;
	    }
	    System.out.println(ans+1);
	}

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

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

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.close();
		in.close();
	}

	private Object solve() throws IOException {
		long n = nl();
		long nn=n;
		LinkedList<Long> primes =new LinkedList<Long>();
		for(long i =2;i*i<=n;i++){
			while(n%i==0L){
				primes.add(i);
				n/=i;
			}
		}
		if(n!=1L)
			primes.add(n);
		long ret = nn;
		while(nn>1L){
			nn/=primes.removeFirst();
			ret+=nn;
		}
		return ret;
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer strTok = new StringTokenizer("");

	String nextToken() throws IOException {
		while (!strTok.hasMoreTokens())
			strTok = new StringTokenizer(in.readLine());
		return strTok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		strTok = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!strTok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			strTok = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}
}

import java.util.Scanner;

public class Main {

    public static void main (String[] args){
        Scanner input = new Scanner (System.in);
        int n,puntos =0;
        n = input.nextInt();
        for(int i=2; n!=1; i++){
            if(n%i==0){
                puntos += n;
                n /=i;
                i=1;
            }
        }
        puntos +=n;
        System.out.println(puntos);
    }

}

import java.util.*;
import java.io.*;

public class b1177
{
	int getcount(int n, int s)
	{
		int newint = 0,p=1,i;
		for(i=s;i<=Math.sqrt(n);i++)
		{
			if(n%i==0)
			{
				newint = n/i;
				break;
			}
		}
		if(newint!=0)
		p = getcount(newint,i);
		return p+n;
	}
	public static void main(String args[])
	{
		int n;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		b1177 ob = new b1177();
		int result = ob.getcount(n,2);
		System.out.println(result);
	}
}

import java.util.Scanner;

public class B1177 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int answer = 1;
        while (N > 1) {
            int divisor = N;
            for (int d=2; d*d <=N; d++) {
                if (N%d == 0) {
                    divisor = d;
                    break;
                }
            }
            answer += N;
            N /= divisor;
        }
        System.out.println(answer);
    }

}

import java.util.Scanner;

public class RectangularGame {
public static void main(String[] args) {
	Scanner scanner=new Scanner(System.in);
	int n=scanner.nextInt();
	if (n<2) {
	}
	else {
		int m=sumgd(n);
		System.out.println(m);
	}

}
static int gd(int n) {
	int gd=1;
	for(int i=1;i<n;i++) {
		if (n%i==0&&i>gd) {
			gd=i;
		}
	}

	return gd;

}
static int sumgd(int n) {
	int k=n;
	while (n>1) {
		k=k+gd(n);
		n=gd(n);
		//System.out.println(k);
	}
	return k;

}
}

//package com.example.programmingpractice;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class CodeforcesNT {

    public static void main (String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = br.readLine().trim().split(" ");
        int n = Integer.parseInt(inputs[0]);
        long sum = n;
        for(int i = 2; i*i<=n; i++) {
            while(n%i == 0) {
                sum += n/i;
                n/=i;
            }
        }
        System.out.println(n == 1 ? sum:sum+1);
    }
}

import java.io.*;
import java.util.*;
import java.util.Queue;
import java.util.LinkedList;
import java.util.Stack;

public class Main
{
    @SuppressWarnings("unchecked")

      public static void main(String args[])throws IOException
    {
         Reader ob=new Reader();
        Writer out=new Writer(System.out);
        Random oo=new Random();
        long n=ob.nL();
        long h=2,sum=n;
        while(n!=1)
        {
            if(h*h>n)
            {
            sum++;
            break;
        }
        if(n%h==0)
        {
            n=n/h;
            sum+=n;
            h=2;

        }
        else
        h++;

        }
        out.pln(sum);

        out.flush();
}
static void sort(int a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static int[] RA(int [] array){
		Random rgen = new Random();  // Random number generator

		for (int i=0; i<array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}

		return array;
	}
	static void sort(long a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static long[] RA(long [] array){
		Random rgen = new Random();  // Random number generator

		for (int i=0; i<array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}

		return array;
	}
	static void sort(String a[])
{
    RA(a);
    Arrays.sort(a);
}
 public static String[] RA(String [] array){
		Random rgen = new Random();  // Random number generator

		for (int i=0; i<array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    String temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}

		return array;
	}
static long inverse(long x, long p)
    {
        return pow(x, p - 2, p);
    }
static boolean isPrime(long n)
{
    long h=(long)Math.sqrt(n);
    for(long i=2;i<=h;i++)
    if(n%i==0)
    return false;
    return true&&n!=1;
}
    static long gcd(long a,long b)
    {
        if(a<b)
        return gcd(b,a);
        else if(b==0)
        return a;
        else
        return gcd(b,a%b);
    }
    static long pow(long a,long b,long mod){
		if(b == 0)	return 1;
		long t = pow(a,b>>1,mod);
		t = (t * t) % mod;
		if((b & 1) == 1)	t = (t * a);
		if(t >= mod)	t %= mod;
		return t;
}
    static long pow(long a,long b){
		if(b == 0)	return 1;
		long t = pow(a,b>>1);
		t = (t * t);
		if((b & 1) == 1)	t = (t * a);
		return t;
}
    static void seive(int n,int prime[])//1 for prime -1 for not prime
    {
        for(int i=2;i<=n;i++)
            if(prime[i]==0)
            {
                prime[i]=1;
                for(int j=2;j*i<=n;j++)
                prime[j*i]=-1;
            }
    }
    static int max(int ...a)
    {
        int m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.max(m,a[i]);
        return m;

    }
    static long max(long ...a)
    {
        long m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.max(m,a[i]);
        return m;
    }
    static int min(int ...a)
    {
        int m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.min(m,a[i]);
        return m;
    }
    static long min(long ...a)
    {
        long m=a[0];
        for(int i=0;i<a.length;i++)
        m=Math.min(m,a[i]);
        return m;
    }
    static class Pair<T1,T2>
    {
        T1 x;T2 y;
        Pair(T1 xx,T2 yy)
        {
            x=xx;
            y=yy;
        }
    }

	static class Writer {
		private final PrintWriter p;
		Writer(OutputStream o) {
			p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(o)));
		}
		void p(Object... o1) {
			for (Object o11 : o1) {
				p.print(o11 + "" );
			}
		}
		void p(String s) {
			p.print(s);
		}
		void pln(Object... o1) {
			p(o1);
			p.println();
		}
		void flush() {
			p.flush();
		}
		void close() {
			p.close();
		}
	}
    static class Reader {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;
		int flag=0;
		FileReader file;
		Reader()
		{
		  }
		  Reader(String x)throws IOException
		  {
		      flag=1;
		      file=new FileReader(x);
		  }
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = System.in.read(buf);

				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		public String nl() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		public String n() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		public long nL() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		public int nI() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		public int[] NIA(int n) //nextINtArray
		{
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nI();
			}
			return arr;
		}
		public int[] NIA1(int n) //nextINtArray
		{
			int[] arr = new int[n+1];
			for (int i = 1; i <=n; i++) {
				arr[i] = nI();
			}
			return arr;
		}

		public long[] NLA(int n) //nextLongArray
		{
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nL();
			}
			return arr;
}
		public long[] NLA1(int n) //nextLongArray
		{
			long[] arr = new long[n+1];
			for (int i = 1; i <=n; i++) {
				arr[i] = nL();
			}
			return arr;
}
		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}
static class DSU
{
    int a[],size[],c=1,m;
    HashMap<String,Integer> hm=new HashMap<String,Integer>();
    DSU(int n)
    {
        a=new int[n+1];
        m=n;
        size=new int[n+1];
        for(int i=1;i<=n;i++)
    {
        a[i]=i;
        size[i]=1;
    }
    }
    void add(String x,int i)
    {
        hm.put(x,i);
    }
    int find(int n)
    {
        while(a[n]!=n)
        {
            a[n]=a[a[n]];
        n=a[n];
    }
        return n;
    }
    int[] eval()
    {
       int y[]=new int[m+1];
       for(int i=1;i<=m;i++)
       y[find(i)]++;
       return y;
    }
    void union(int a1,int b)
    {
        int x=find(a1);
        int y=find(b);
        if(size[x]>size[y])
    {
        a[y]=x;
        size[x]+=size[y];
    }
    else
    {
       a[x]=y;
       size[y]+=size[x];
    }
}
        //System.out.println(Arrays.toString(a));
     int query(String x,String y)
     {
         int p=-1,q=-1;
         if(hm.containsKey(x))
         p=hm.get(x);
         else
         {
             p=c;
         hm.put(x,c++);

        }
         if(hm.containsKey(y))
         q=hm.get(y);
         else
         {
             q=c;
         hm.put(y,c++);
        }
        int m=find(p),n=find(q);
        if(m!=n)
        {
        union(m,n);
            return 2;
        }
        else
        return 1;
}
}
class Segment
{
    int sum[];
    void build(int a[],int v,int l,int r)
    {
        if(l==r)
        sum[v]=a[l];
        else
        {
            int m=(l+r)/2;
            build(a,v*2,l,m);
            build(a,2*v+1,m+1,r);
            sum[v]=sum[v*2]+sum[2*v+1];
        }
    }
    void update(int a[],int l,int r,int x,int v,int y)
    {
        if(l==r&&r==y)
            sum[v]+=x;
        else if(l>y||y>r)
        return;
        else
        {
            int m=(l+r)/2;
            update(a,l,m,x,2*v,y);
            update(a,m+1,r,x,2*v+1,y);
            sum[v]=sum[2*v]+sum[2*v+1];
        }
    }
    int query(int v,int l,int r,int x,int y)
    {
        if(x>r||y<l)
        return 0;
        else if(x<=l&&r<=y)
        return sum[v];
        else
        {
            int m=(l+r)/2;
        return query(2*v,l,m,x,y)+query(2*v+1,m+1,r,x,y);
    }
}
}

static class Trie
  {
      Trie child[]=new Trie[26];
      int count=0;
    }
   /* void insert(String a)
    {
        Trie tmp=root;
        for(int i=0;i<a.length();i++)
        {
            int v=a.charAt(i)-'a';
            if(tmp.child[v]==null)
            {
                tmp.child[v]=new Trie();

            }
                tmp=tmp.child[v];
            }
            if(tmp.count==0)
            r++;
            tmp.count=1;
        }*/
    }

import java.util.*;
public class Main
{

    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int sum=n;
        while(n!=1)
        {
           for(int i=2; i<=n; i++)
               if(n%i==0)
               {
                   n = n / i;
                   break;
               }
            sum+=n;
        }
        System.out.println(sum);
    }
}

//package com.example.programmingpractice;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class CodeforcesNT {

    public static void main (String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        long sum = n;
        while(n != 1) {
            boolean isNotFound = true;
            for(int i = 2; i*i<=n; i++) {
                if(n%i == 0) {
                    n /= i;
                    sum += n;
                    isNotFound = false;
                    break;
                }
            }
            if(isNotFound) {
                sum += 1; break;
            }
        }
        System.out.println(sum);
    }
}

import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Nguyen Trung Hieu - vuondenthanhcong11@yahoo.com
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB1 solver = new TaskB1();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB1 {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int count = in.readInt();
        List<Pair<Integer, Integer>> divisors = IntegerUtils.factorize(count);
        Collections.sort(divisors);

        long answer = 0;
        int cur = count;
        for (Pair<Integer, Integer> x : divisors) {
            for (int i = 0; i < x.second; i++) {
                cur /= x.first;
                answer += cur;
            }
        }

        out.printLine(answer + count);
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

}

class Pair<U, V> implements Comparable<Pair<U, V>> {

    public final U first;
    public final V second;

    public static<U, V> Pair<U, V> makePair(U first, V second) {
        return new Pair<U, V>(first, second);
    }

    private Pair(U first, V second) {
        this.first = first;
        this.second = second;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Pair pair = (Pair) o;

        return !(first != null ? !first.equals(pair.first) : pair.first != null) && !(second != null ? !second.equals(pair.second) : pair.second != null);

    }

    public int hashCode() {
        int result = first != null ? first.hashCode() : 0;
        result = 31 * result + (second != null ? second.hashCode() : 0);
        return result;
    }

    public String toString() {
        return "(" + first + "," + second + ")";
    }

    public int compareTo(Pair<U, V> o) {
        int value = ((Comparable<U>)first).compareTo(o.first);
        if (value != 0)
            return value;
        return ((Comparable<V>)second).compareTo(o.second);
    }
}

class IntegerUtils {

    public static List<Pair<Integer, Integer>> factorize(int number) {
        List<Pair<Integer, Integer>> result = new ArrayList<Pair<Integer, Integer>>();
        for (int i = 2; i * i <= number; i++) {
            if (number % i == 0) {
                int power = 0;
                do {
                    power++;
                    number /= i;
                } while (number % i == 0);
                result.add(Pair.makePair(i, power));
            }
        }
        if (number != 1)
            result.add(Pair.makePair(number, 1));
        return result;
    }

    }

//package contest_abbyy_easy;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
/**
 * Date     : 30.04.2012
 * Time     : 9:57:33
 * Email    : denys.astanin@gmail.com
 */

public class B1 {
	public static void main(String[] args) throws IOException {
		new B1().run();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return (String) in.sval;
	}

	StreamTokenizer in;
	Writer writer;
	Reader reader;

	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("src/contest_abbyy_easy/B1.txt");
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		in = new StreamTokenizer(new BufferedReader(reader));
		PrintWriter out = new PrintWriter(writer);
		int n = nextInt();
		out.println(result(n));
		out.flush();
		out.close();
	}

	private int result(int n) {
		if (n == 1)
			return 1;

		int result = 0;
		for (int i = 1; i <= n / 2; i++) {
			if (n % i == 0) {
				result = Math.max(result, result(i) + n);
			}
		}
		return result;
	}
}

import java.util.*;

public class ABBY_2_b {

	static long sum=0;
	static long max = 0;

	/*             Miller                           */

	static long gcd(long a, long b){
		return (b == 0 ? a : gcd(b, a%b));
	}

	static long binpow(long a, long b, long p){
		if (b == 0) return 1;
		if (b%2==1) return (binpow(a, b-1, p)*a)%p;
		else {
			long t = binpow(a, b/2, p);
			return (t*t)%p;
		}
	}

	static boolean isPrime(long n){
		long a = 2;
		for (int i = 0; i<10; i++){
			while (gcd(a, n)!=1) a++;
			if (binpow(a, n-1, n) != 1) return false;
		}
		return true;
	}

	static void R(long n, long sum){
		if (n == 1) {  if (sum > max) max = sum; return;}
		if (isPrime(n)) R(1, sum+1);
		else
		for (int i = 2; i <= n; i++)
			if (n%i==0) {
				R(n/i, sum + n/i);
				break;
			}
	}

	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		long n = in.nextLong();
		R(n, n);
		System.out.println(max);
	}

}

import java.util.*;
import java.io.*;

public class Main implements Runnable {

	public void solve() throws IOException {
		int N = nextInt();
                long answer = N;

                    for(int i = 2; i*i <= N; i++){
                        if(N % i == 0){
                            while(N%i == 0){
                                N = N / i;
                                answer += N;
                            }
                        }
                    }

                 if(N > 1) answer += 1;

                 System.out.println(answer);
	}

	//-----------------------------------------------------------
	public static void main(String[] args) {
		new Main().run();
	}

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }

        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tok = null;
			solve();
			in.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	BufferedReader in;
	StringTokenizer tok;
}

import java.io.*;
import java.util.*;

public class Main {
    private IO io;
    private int ioMode = -1;
    private String problemName = "";
    private final String mjArgument = "master_j";

    public static void main(String programArguments[]) throws IOException{
        if(programArguments != null && programArguments.length > 0)
            new Main().run(programArguments[0]);
        else
            new Main().run(null);
    }

    private void run(String programArgument) throws IOException {
//         _______________________________________________ _________
//        |   Input Mode     |      Output Mode    | mode | comment |
//        |------------------|---------------------|----- |---------|
//        |   input.txt      |      System.out     |  0   |    mj   |
//        |   System.in      |      System.out     |  1   |  T / CF |
//        |<problemName>.in  |  <problemName>.out  |  2   |         |
//        |   input.txt      |      output.txt     |  3   |    C    |
//        |__________________|_____________________|______|_________|
        if(programArgument != null && programArgument.equals(mjArgument)) // mj
            ioMode = 0;
        else if(System.getProperty("ONLINE_JUDGE") != null) // T / CF
            ioMode = 1;
        else
            ioMode = 2;

        switch(ioMode){
            case -1:
                try{
                    throw new Exception("<ioMode> init failure") ;
                }catch (Exception e){
                    e.printStackTrace();
                }
                return;
            case 0:
                break;
            case 1:
                break;
            case 2:
                if(problemName.length() == 0){
                    try{
                        throw new Exception("<problemName> init failure");
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    return;
                }
            case 3:
                break;
        }
        io = new IO(ioMode, problemName);
        if(ioMode == 0){
            System.out.println("File output : \n<start>");
            System.out.flush();
        }
        solve();
        io.flush();
        if(ioMode == 0){
            System.out.println("</start>");
            System.out.flush();
        }
    }

    private void solve() throws IOException {
        int n = io.nI(); long r = n;
        for(int i = 2; i*i<=n; i++){
            int t = n % i;
            if(n % i == 0){
                n /= i;
                r += n;
                i--;
            }
        }
        io.wln(r + 1);
    }//2.2250738585072012e-308

    /**
     * Input-output class
     * @author master_j
     * @version 0.2.0
     */
    @SuppressWarnings("unused")
    private class IO{
        StreamTokenizer in; PrintWriter out; BufferedReader br; Reader reader; Writer writer;
        public IO(int ioMode, String problemName) throws IOException{
            Locale.setDefault(Locale.US);
//         _______________________________________________ _________
//        |   Input Mode     |      Output Mode    | mode | comment |
//        |------------------|---------------------|----- |---------|
//        |   input.txt      |      System.out     |  0   |    mj   |
//        |   System.in      |      System.out     |  1   |  T / CF |
//        |<problemName>.in  |  <problemName>.out  |  2   |         |
//        |   input.txt      |      output.txt     |  3   |    C    |
//        |__________________|_____________________|______|_________|
            switch(ioMode){
                case 0:
                    reader = new FileReader("input.txt");
                    writer = new OutputStreamWriter(System.out);
                    break;
                case 1:
                    reader = new InputStreamReader(System.in);
                    writer = new OutputStreamWriter(System.out);
                    break;
                case 2:
                    reader = new FileReader(problemName + ".in");
                    writer = new FileWriter(problemName + ".out");
                    break;
                case 3:
                    reader = new FileReader("input.txt");
                    writer = new FileWriter("output.txt");
                    break;
            }
            br = new BufferedReader(reader);
            in = new StreamTokenizer(br);
            out = new PrintWriter(writer);
        }
        public void wln(){out.println();}
        public void wln(int arg){out.println(arg);}
        public void wln(long arg){out.println(arg);}
        public void wln(double arg){out.println(arg);}
        public void wln(String arg){out.println(arg);}
        public void wln(boolean arg){out.println(arg);}
        public void wln(char arg){out.println(arg);}
        public void wln(float arg){out.println(arg);}
        public void wln(Object arg){out.println(arg);}
        public void w(int arg){out.print(arg);}
        public void w(long arg){out.print(arg);}
        public void w(double arg){out.print(arg);}
        public void w(String arg){out.print(arg);}
        public void w(boolean arg){out.print(arg);}
        public void w(char arg){out.print(arg);}
        public void w(float arg){out.print(arg);}
        public void w(Object arg){out.print(arg);}
        public void wf(String format, Object...args){out.printf(format, args);}
        public void flush(){out.flush();}
        public int nI() throws IOException {in.nextToken(); return(int)in.nval;}
        public long nL() throws IOException {in.nextToken(); return(long)in.nval;}
        public String nS() throws IOException {in.nextToken(); return in.sval;}
        public double nD() throws IOException {in.nextToken(); return in.nval;}
        public float nF() throws IOException {in.nextToken(); return (float)in.nval;}
        public void wc(char...a){for(char c : a){in.ordinaryChar(c);in.wordChars(c, c);}}
        public void wc(char c1, char c2){in.ordinaryChars(c1, c2); in.wordChars(c1, c2);}
    }
}

import java.util.Scanner;

public class B177 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int res = n;
        while (true) {
            int i = 2;
            boolean found = false;
            while (i * i <= n) {
                if (n % i == 0) {
                    found = true;
                    break;
                }
                i++;
            }
            if (found) {
                res += n / i;
                n = n / i;
            } else {
                res++;
                break;
            }
        }
        System.out.println(res);
    }
}

import java.math.*;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

}

class Task {

    public void solve(FastReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        ArrayList<Integer> dp = new ArrayList<Integer>();
        ArrayList<Integer> di = new ArrayList<Integer>();
        for(int i = 1; i * i <= n; ++i) {
            if(n % i == 0) {
                dp.add(0);
                di.add(i);
                if(i * i != n) {
                    dp.add(0);
                    di.add(n / i);
                }
            }
        }
        Collections.sort(di);
        dp.set(0, 1);
        for(int i = 1; i < di.size(); ++i) {
            for(int j = 0; j < i; ++j) {
                if(di.get(i) % di.get(j) == 0) {
                    int val = Math.max(dp.get(i), dp.get(j) + di.get(i));
                    dp.set(i, val);
                }
            }
        }
        out.println(dp.get(dp.size() - 1));
    }

}

class FastReader {

    BufferedReader in;
    StringBuilder sb = new StringBuilder();

    public FastReader(BufferedReader in) {
        this.in = in;
    }

    public String next() throws IOException {
        sb.setLength(0);
        while(true) {
            int c = in.read();
            if(c == -1) {
                return null;
            }
            if(" \n\r\t".indexOf(c) == -1) {
                sb.append((char)c);
                break;
            }
        }
        while(true) {
            int c = in.read();
            if(c == -1 || " \n\r\t".indexOf(c) != -1) {
                break;
            }
            sb.append((char)c);
        }
        return sb.toString();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class RectangularGame {
	public static void main(String[] args) {
		PrintWriter pw = new PrintWriter(System.out);
	    reader(System.in);
	    int n = nI();
	    int sum = n;
	    while (n != 1) {
	    	n = div(n);
	    	sum += n;
	    }
	    pw.println(sum);
	    pw.close();
	}

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

	private static BufferedReader br;
	private static StringTokenizer st;

	static void reader(InputStream stream) {
	    try {
	        br = new BufferedReader(new InputStreamReader(stream));
	    } catch (Exception e) {
	        e.printStackTrace();
	    }
	}

	static String n() {
	    while (st == null || !st.hasMoreTokens()) {
	        try {
	            st = new StringTokenizer(br.readLine());
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	    }
	    return st.nextToken();
	}

	static int nI() {
	    return Integer.parseInt(n());
	}

	static long nL() {
	    return Long.parseLong(n());
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class B1177 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        long n   = in.nextLong();
        long count = n,temp;
        while(n!=1){
            for(int l=2;l<=n;l++){
                if(n%l==0){
                    count+=(n/l);
                    n = n/l;
                    break;
                }
            }
        }
        System.out.println(count);
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

import java.io.*;
import java.util.*;

public class Main {
    int ans = 0;
    Map< Integer, Integer > vis = new HashMap< Integer, Integer >( );
    int dfs( int n ) {
        int max = 1;

        if ( vis.containsKey( n ) ) {
            return vis.get( n );
        }
        for ( int i = 2; i * i <= n; ++i ) {
            if ( n % i == 0 ) {
                max = Math.max( max, dfs( n / i ) );
                max = Math.max( max, dfs( i ) );
            }
        }
        vis.put( n, max );
        return max + n;

    }
    public void solve( ) throws Throwable {
        int n = in.nextInt( );
        out.println( dfs( n ) );
    }

    public void run( ) {
        in = new FastScanner( System.in );
        out = new PrintWriter( new PrintStream( System.out ), true );

        try {
            solve( );
            out.close( );
            System.exit( 0 );
        } catch( Throwable e ) {
            e.printStackTrace( );
            System.exit( -1 );
        }
    }

    public void debug( Object...os ) {
        System.err.println( Arrays.deepToString( os ) );
    }

    public static void main( String[ ] args ) {
        ( new Main( ) ).run( );
    }

    private FastScanner in;
    private PrintWriter out;

    private static class FastScanner {
        private int charsRead;
        private int currentRead;
        private byte buffer[ ] = new byte[ 0x1000 ];
        private InputStream reader;

        public FastScanner( InputStream in ) {
            reader = in;
        }

        public int read( ) {
            if ( charsRead == -1 ) {
                throw  new InputMismatchException( );
            }

            if ( currentRead >= charsRead ) {
                currentRead = 0;
                try {
                    charsRead = reader.read( buffer );

                } catch( IOException e ) {
                    throw new InputMismatchException(  );
                }

                if ( charsRead <= 0 ) {
                    return -1;
                }
            }

            return buffer[ currentRead++ ];
        }

        public int nextInt( ) {
            int c = read( );

            while ( isWhitespace( c ) ) {
                c = read( );
            }

            if ( c == -1 ) {
                throw new NullPointerException( );
            }

            if ( c != '-' && !( c >= '0' && c <= '9' ) ) {
                throw new InputMismatchException( );
            }

            int sign = c == '-' ? -1 : 1;
            if ( sign == -1 ) {
                c = read( );
            }

            if ( c == -1 || !( c >= '0' && c <= '9' ) ) {
                throw new InputMismatchException( );
            }

            int ans = 0;
            while ( !isWhitespace( c )  && c != -1 ) {
                if ( !( c >= '0' && c <= '9' ) ) {
                    throw  new InputMismatchException( );
                }
                int num = c - '0';
                ans = ans * 10 + num;
                c = read( );
            }

            return ans * sign;
        }

        public long nextLong( ) {
            int c = read( );

            while ( isWhitespace( c ) ) {
                c = read( );
            }

            if ( c == -1 ) {
                throw new NullPointerException( );
            }

            if ( c != '-' && !( c >= '0' && c <= '9' ) ) {
                throw new InputMismatchException( );
            }

            int sign = c == '-' ? -1 : 1;
            if ( sign == -1 ) {
                c = read( );
            }

            if ( c == -1 || !( c >= '0' && c <= '9' ) ) {
                throw new InputMismatchException( );
            }

            long ans = 0;
            while ( !isWhitespace( c )  && c != -1 ) {
                if ( !( c >= '0' && c <= '9' ) ) {
                    throw  new InputMismatchException( );
                }
                int num = c - '0';
                ans = ans * 10 + num;
                c = read( );
            }

            return ans * sign;
        }

        public boolean isWhitespace( int c ) {
            return  c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == -1;
        }

        public String next( ) {
            int c = read( );
            StringBuffer ans = new StringBuffer( );

            while ( isWhitespace( c ) && c != -1 ) {
                c  = read( );
            }

            if ( c == -1 ) {
                return null;
            }

            while ( !isWhitespace( c ) && c != -1 ) {
                ans.appendCodePoint( c );
                c = read( );
            }

            return ans.toString( );

        }

        public String nextLine( ) {
            String ans = nextLine0( );

            while ( ans.trim( ).length( ) == 0 ) {
                ans = nextLine0( );
            }

            return ans;
        }

        private String nextLine0( ) {
            int c = read( );
            if ( c == -1 ) {
                return null;
            }
            StringBuffer ans = new StringBuffer( );
            while ( c != '\n' && c != '\r' && c != -1 ) {
                ans.appendCodePoint( c );
                c = read( );
            }

            return ans.toString( );

        }

        public double nextDouble( ) {
            int c = read( );
            while ( isWhitespace( c ) ) {
                c = read( );
            }

            if ( c == -1 ) {
                throw new NullPointerException( );
            }

            if ( c != '.' && c != '-' && !( c >= '0' && c <= '9' ) ) {
                throw new InputMismatchException( );
            }

            int sign = c == '-' ? -1 : 1;
            if ( c == '-' ) {
                c = read( );
            }
            double ans = 0;
            while ( c != -1 && c != '.' && !isWhitespace( c ) ) {
                if ( !( c >= '0' && c <= '9' ) ) {
                    throw new InputMismatchException( );
                }

                int num = c - '0';
                ans = ans * 10.0 + num;
                c = read( );
            }

            if ( !isWhitespace( c ) && c != -1 && c != '.' ) {
                throw new InputMismatchException( );
            }

            double pow10 = 1.0;

            if ( c == '.' ) {
                c = read( );
            }

            while ( !isWhitespace( c ) && c != -1 ) {
                pow10 *= 10.0;

                if ( !( c >= '0' && c <= '9' ) ) {
                    throw new InputMismatchException( );
                }
                int num = c - '0';
                ans = ans * 10.0 + num;
                c = read( );
            }

            return ans * sign / pow10;
        }
    }

}

import java.io.*;
import java.util.*;
import java.math.*;
public class cc{
    public static void main(String args[])throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
       int c=n;
    while(n>1){
        for(int j=2;j<=n;j++){
        if(n%j==0){
        n/=j;
        break;
        }
    }
        c+=n;
    }
    System.out.println(c);
    }
}

import java.util.Scanner;

public class Easy {
    static int check(int x) {
        double b = java.lang.Math.sqrt((double)x);
        for (int i = 2 ; i <= b+1; i++) {
            if (x % i == 0) return i;
        }
        return -1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        sum += n;
        while(true) {
            int d = check(n);
            if (d >-1 && n != 2) {
                sum += n/d;
                n/=d;
            }
            else {
                sum++;
                break;
            }
        }

        System.out.println(sum);
        sc.close();
    }
}

import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        int n = new Scanner(System.in).nextInt();
        long ans = n;
        while (true){
            int t = n;
            for (int i = 2; i*i <=n; i++) {
                if (n%i == 0){
                    ans += n/i;
                    n /= i;
                    break;
                }
            }
            if (n == t) break;
        }
        ans++;
        System.out.println(ans);
    }
}

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class ABBYY_Cup_2012_Div2_B implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new ABBYY_Cup_2012_Div2_B(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (ONLINE_JUDGE) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	void debug(Object... o) {
		if (!ONLINE_JUDGE) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution

	void solve() throws IOException {
		long n = readLong();
		List<Long> list = new ArrayList<Long>();
		long nn = n;
		for (long i = 2; i * i <= nn; i++) {
			while (n % i == 0) {
				list.add(i);
				n /= i;
			}
		}
		if (n != 1) {
			list.add(n);
		}
		Collections.sort(list);
		long ans = nn;
		for (long i : list) {
			ans += nn / i;
			nn /= i;
		}
		out.println(ans);
	}

}

import java.util.*;
public class B {
	Scanner sc = new Scanner(System.in);
	void doIt()
	{
		int ans = solve(sc.nextInt());
		System.out.println(ans);
	}
	int solve(int n)
	{
		int ans = 0;
		while(n != 1) {
			ans += n;
			n = f(n);
			//System.out.println(n);
		}
		ans += n;
		return ans;
	}
	int f(int n)
	{
		for(int i = 2; i*i <= n; i++)
			if(n % i == 0) return n / i;
		return 1;
	}
	public static void main(String[] args) {
		new B().doIt();
	}

}

import java.io.*;
import java.util.*;

public final class RectangularGame
{
    public static void main(String[] args)
    {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
		Solver solver = new Solver(in, out);

		solver.solve();
        in.close();
        out.flush();
        out.close();
    }

    static class Solver
    {
        int n, lim;
        int[] spf;
        List<Integer> primes;
        InputReader in;
        PrintWriter out;

		void solve()
		{
			pre();
			n = in.nextInt();

			int ans = 0;

			while (n > 1)
			{
				int x = getSPF(n);

				ans += n;
				n /= x;

				if (n == 1)
					break;
			}

			out.println(ans + 1);
		}

		void pre()
		{
			lim = (int) Math.sqrt(1e9);
			spf = new int[lim + 5];
			spf[2] = 2;
			primes = new ArrayList<>();
			primes.add(2);

			int curr = 2;

			while ((curr << 1) <= lim)
			{
				spf[curr << 1] = 2;
				curr++;
			}

			for (int i = 3; i <= lim; i += 2)
			{
				if (spf[i] != 0)
					continue;

				spf[i] = i;
				primes.add(i);
				curr = i + i;

				while (curr <= lim)
				{
					if (spf[curr] == 0)
						spf[curr] = i;

					curr += i;
				}
			}
		}

		int getSPF(int x)
		{
			if (x <= lim)
				return spf[x];

			int sqrt = (int) Math.sqrt(x);

			for (int p : primes)
			{
				if (p > sqrt)
					return x;

				if (x % p == 0)
					return p;
			}

			return x;
		}

        public Solver(InputReader in, PrintWriter out)
        {
        	this.in = in;
        	this.out = out;
        }

	}

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                } catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public void close()
        {
            try
            {
                stream.close();
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }

    }

}

import java.util.Scanner;

public class B_Abba {
	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		if (n==2){
			System.out.println(3);return;
		}
		boolean f = false;
		long sum = n;
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0) {
				f = true;
				break;
			}
		}
		if (!f) {
			System.out.println(n+1);
		} else {
			while (n > 1) {
				sum = sum + gcd(n);
			}
			System.out.println(sum);
		}
	}

	private static long gcd(int a) {
		for (int i = 2; i <= a; i++) {
			if (a % i == 0) {
				n /= i;
				break;
			}
		}
		return n;
	}
}

    import java.util.Scanner;
import java.util.Scanner;

    public class B2 {
        static int i,j,n,f;
        static long k;
        static long s=0;
        static public void func(){
            k=Math.round(Math.sqrt(n));
            f=0;
            for(i=2;i<=k+1;i++){
             if(n%i==0){
                 f=1;
                 s+=n/i;
                 n=n/i;
                 break;
             }
            }
            if(f==0){
                s+=1;
                n=1;
            }
        }
        public static void main(String[] args) {
            Scanner in=new Scanner(System.in);
            /*int i,j,n,f;
            long k;
            long s=0;
            int[][] a=new int[1000][1000];*/
            n=in.nextInt();
            s+=n;
            while(n!=1){
                func();
            }
            System.out.println(s);
        }

    }

import java.util.Scanner;
public class Ishu
{
	public static void main(String[] args)
	{
	Scanner scan=new Scanner(System.in);
	int n,i,sum;
	boolean flag=true;
	n=scan.nextInt();
	sum=n;
	while(n>1)
		{
		flag=true;
		for(i=2;i<=Math.sqrt(n);++i)
			{
			if(n%i==0)
				{
				n=n/i;
				sum+=n;
				flag=false;
				break;
				}
			}
		if(flag)
			{
			n=1;
			sum+=n;
			}
		}
	System.out.println(sum);
	}
}

import java.util.*;
import java.io.*;

public class RectangularGame {
    InputStream is;
    PrintWriter out;
    String INPUT = "";

    void solve() throws IOException {
        long n= nl();
        long ans=0;

        while(n!=1)
        {
            ans+= n;

            long i=2;
            while(n%i!=0 && i*i<= n)
                i++;

            if(i*i<=n)
                n= n/i;
            else
                break;
        }

        out.println(ans+1);
    }

    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }

    public static void main(String[] args) throws Exception {
        new RectangularGame().run();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private void tr(Object... o) {
        if (INPUT.length() > 0) System.out.println(Arrays.deepToString(o));
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class B177 {

    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

    static int nextInt() throws Exception {
        in.nextToken();
        return (int)in.nval;
    }

    static String nextString() throws Exception {
        in.nextToken();
        return in.sval;
    }

    public static void main(String[] args) throws Exception {
        int x = nextInt();
        long ans = 1;
        for (int d = 2; d*d <= x; d++) {
            while (x%d == 0) {
                ans += x;
                x /= d;
            }
        }
        if (x > 1) ans += x;
        out.println(ans);
        out.flush();
    }

}

import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException	{
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = readInt();
		long ret = n;
		int d = 2;
		while(n > 1)	{
			while(n%d != 0)	{
				d++;
				if(d*d > n)
					break;
			}
			if(n%d != 0)	{
				ret++;
				n = 1;
			}
			else	{
				n /= d;
				ret += n;
			}
		}
		pw.println(ret);
		pw.close();
	}

	/* NOTEBOOK CODE */

	public static void loadArray(int[][] grid) throws IOException {
		for(int[] a: grid)
			loadArray(a);
	}

	public static void loadArray(int[] in) throws IOException {
		for(int i = 0; i < in.length; i++)
			in[i] = readInt();
	}

	public static void loadArray(long[] in) throws IOException {
		for(int i = 0; i < in.length; i++)
			in[i] = readLong();
	}

	private static long readLong() throws IOException	{
		return Long.parseLong(nextToken());
	}

	private static double readDouble() throws IOException	{
		return Double.parseDouble(nextToken());
	}

	private static int readInt() throws IOException	{
		return Integer.parseInt(nextToken());
	}

	private static String nextToken() throws IOException	{
		while(st == null || !st.hasMoreTokens())	{
			if(!br.ready())	{
				pw.close();
				System.exit(0);
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}

import java.io.*;
import java.util.*;

/**
 * _177B
 * O(n^(2/3)) time
 * O(n^(1/3)) space
 *
 * @author artyom
 */
public class _177B implements Runnable {
    private BufferedReader in;
    private PrintStream out;
    private StringTokenizer tok;
    private int[] divs;
    private int[] dp;

    private void solve() throws IOException {
        int n = nextInt(), q = (int) Math.sqrt(n);
        List<Integer> ls = new ArrayList<>();
        for (int i = 2; i <= q; i++) {
            if (n % i == 0) {
                ls.add(i);
            }
        }
        int t = ls.size();
        divs = new int[q * q == n ? 2 * t : 2 * t + 1];
        for (int i = 0; i < t; i++) {
            divs[i] = ls.get(i);
        }
        for (int i = 1, l = divs.length / 2; i <= l; i++) {
            divs[divs.length - i - 1] = n / ls.get(i - 1);
        }
        divs[divs.length - 1] = n;
        dp = new int[divs.length];
        out.print(findMax(divs.length - 1));
    }

    private int findMax(int i) {
        if (dp[i] == 0) {
            int s = divs[i], max = 1;
            for (int j = i - 1; j >= 0; j--) {
                if (divs[i] % divs[j] == 0) {
                    max = Math.max(max, findMax(j));
                }
            }
            dp[i] = s + max;
        }
        return dp[i];
    }

    //--------------------------------------------------------------
    public static void main(String[] args) {
        new _177B().run();
    }

    @Override
    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = System.out;
            tok = null;
            solve();
            in.close();
        } catch (IOException e) {
            System.exit(0);
        }
    }

    private String nextToken() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
}

import java.io.*;

import java.util.*;

public class CodeForces {

	public void solve() throws IOException {
		int n = nextInt();
		long sum = n;
		double sq = Math.sqrt(n);
		boolean arr[] = new boolean[(int)Math.ceil(sq) + 1];
		Arrays.fill(arr, true);
		int a = 2;
		List<Integer> ls = new ArrayList<Integer>();

		while (a <= sq) {
			if (arr[a]) {
				int t = 2 * a;
				while (t <= sq) {
					arr[t] = false;
					t += a;
				}
				ls.add(a);
			}
			a++;
		}
		int l = ls.size();
		while (n > 1) {
			int i = 0;
			while (i<l && n % ls.get(i) != 0) {
				i++;
			}
			if(i==l) {
				n = 1;
			} else {
				n = n / ls.get(i);
			}
			sum += n;
		}
		out.println(sum);

	}

	public static void main(String[] args) {
		new CodeForces().run();
	}

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter(new BufferedWriter(new FileWriter(
						"output.txt")));
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;
			//long time = new Date().getTime();
			solve();
			//out.println(time - new Date().getTime());
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

import java.io.*;
import java.util.*;

public class Main {
   private static IO io;

   public static void main(String[] args) throws IOException {
       new Main().run();
   }

   private void run() throws IOException {
       io = new IO(System.getProperty("ONLINE_JUDGE")!=null);
       solve();
       io.flush();
   }

   private void solve() throws IOException {
       int n = io.nI(); long r = n;
       while(n>1){
           int d = maxDiv(n);
           r+=d;
           n = d;
       }
       io.wln(r);
   }//2.2250738585072012e-308

   private int maxDiv(int n){
       for(int i = n/2; i>1; i--)
           if(n%i==0)return i;
       return 1;
   }

   @SuppressWarnings("unused")
   private class IO{
       StreamTokenizer in; PrintWriter out; BufferedReader br; Reader reader; Writer writer;
       public IO(boolean oj) throws IOException{
           Locale.setDefault(Locale.US);
           reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
           writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
           br = new BufferedReader(reader);
           in = new StreamTokenizer(br);
           out = new PrintWriter(writer);
       }
       public void wln(){out.println();}
       public void wln(int arg){out.println(arg);}
       public void wln(long arg){out.println(arg);}
       public void wln(double arg){out.println(arg);}
       public void wln(String arg){out.println(arg);}
       public void wln(boolean arg){out.println(arg);}
       public void wln(char arg){out.println(arg);}
       public void wln(float arg){out.println(arg);}
       public void wln(Object arg){out.println(arg);}
       public void w(int arg){out.print(arg);}
       public void w(long arg){out.print(arg);}
       public void w(double arg){out.print(arg);}
       public void w(String arg){out.print(arg);}
       public void w(boolean arg){out.print(arg);}
       public void w(char arg){out.print(arg);}
       public void w(float arg){out.print(arg);}
       public void w(Object arg){out.print(arg);}
       public void wf(String format, Object...args){out.printf(format, args);}
       public void flush(){out.flush();}
       public int nI() throws IOException {in.nextToken(); return(int)in.nval;}
       public long nL() throws IOException {in.nextToken(); return(long)in.nval;}
       public String nS() throws IOException {in.nextToken(); return in.sval;}
       public double nD() throws IOException {in.nextToken(); return in.nval;}
       public float nF() throws IOException {in.nextToken(); return (float)in.nval;}
       public void wc(char...a){for(char c : a){in.ordinaryChar(c);in.wordChars(c, c);}}
       public void wc(char c1, char c2){in.ordinaryChars(c1, c2); in.wordChars(c1, c2);}
   }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    class GraphBuilder {
        int n, m;
        int[] x, y;
        int index;
        int[] size;

        GraphBuilder(int n, int m) {
            this.n = n;
            this.m = m;
            x = new int[m];
            y = new int[m];
            size = new int[n];
        }

        void add(int u, int v) {
            x[index] = u;
            y[index] = v;
            size[u]++;
            size[v]++;
            index++;
        }

        int[][] build() {
            int[][] graph = new int[n][];
            for (int i = 0; i < n; i++) {
                graph[i] = new int[size[i]];
            }
            for (int i = index - 1; i >= 0; i--) {
                int u = x[i];
                int v = y[i];
                graph[u][--size[u]] = v;
                graph[v][--size[v]] = u;
            }
            return graph;
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long[] readLongArray(int size) throws IOException {
        long[] res = new long[size];
        for (int i = 0; i < size; i++) {
            res[i] = readLong();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
        // new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    void solve() throws IOException {
        int n = readInt();
        int sn = n;
        long answer = n;
        List<Integer> primes = new ArrayList<>();
        for (int i = 2; (long) i * i <= n; i++) {
            while (n % i == 0) {
                primes.add(i);
                n /= i;
            }
        }
        if (n > 1)
            primes.add(n);
        Collections.sort(primes);
        for (int prime : primes) {
            answer += (sn = sn / prime);
        }
        out.println(answer);

    }

}

import java.io.*;
import java.util.*;
public class B2 {
	public void solve() throws IOException {
		int n = nextInt();
		writer.println(go(n));
	}

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

	public static void main(String[] args) throws FileNotFoundException {
		new B2().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			long tbegin = System.currentTimeMillis();
			reader = new BufferedReader(new InputStreamReader(System.in));
			//reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			//writer = new PrintWriter(new FileOutputStream("output.txt"));
			solve();
			//reader.close();
			//System.out.println(System.currentTimeMillis() - tbegin + "ms");
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

}

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();int count =n;
        while(n>1){
            for(int i=2;i<=n/2+1;i++){
                if(n%i==0){
                    n=n/i;
                    count+=n;
                    break;
                }else if(i==n/2+1 || n==i){
                    n=1;
                    count+=1;
                    break;
                }
            }
        }
        System.out.println(count);
    }

}

import java.util.Scanner;

public class B {
    static int n;

    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        // -----------begin-------------------------
        n = sc.nextInt();;
        boolean f = false;
        for (int i = 2; i <= (int)(Math.sqrt(n)); i++) {
            if (n%i == 0){
                f = true;
                break;
            }
        }
        if (!f){
            System.out.println(n+1);
            return;
        }
        long sum = n;
        while (n>1) {
            sum += top(n);
        }
        System.out.println(sum);
        // ------------end--------------------------
    }

    static public int top(int a) {
        for (int i = 2; i <= a; i++) {
            if (a % i == 0) {
                n /= i;
                break;
            }
        }
        return n;
    }

}

import java.io.*;
import java.util.*;

public class B {

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

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

	void solve() throws Exception {
		int n = nextInt();
		out.println(get(n) + n);
	}

	void run() {
		try {
			Locale.setDefault(Locale.US);
			boolean oj = System.getProperty("ONLINE_JUDGE") != null;
			Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
			Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
			in = new BufferedReader(reader);
			out = new PrintWriter(writer);
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new B().run();

	}

}

import java.util.Scanner;
public class B1177 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int c=n;
        while(n!=1){
        for(int i=2;i<=n;i++)
        {
        if(n%i==0)
           {
            n/=i;
            c+=n;
            break;

           }
        }
        }
        System.out.println(""+c);
    }
}

import java.util.Scanner;

public class Codeforces177B1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        int cur = (int) Math.sqrt(n);
        boolean[] a = new boolean[cur + 1];
        a[0] = false;
        for (int i = 1; i < cur + 1; i++) {
            if (i % 2 == 1) {
                a[i] = false;
            } else {
                a[i] = true;
            }
        }
        long kol = n;
        while (n != 1) {
            int i = 2;
            boolean p = false;
            if (n % i != 0) {
                for (int j = i; j < cur + 1; j += 2) {
                    if (a[j] == true && n % (j + 1) == 0) {
                        i = j + 1;
                        p = true;
                        break;
                    } else {
                        a[j] = false;
                        for (int q = (j + 1) * (j + 1) - 1; q < cur; q += (j + 1)) {
                            a[q] = false;
                        }
                    }
                }
            } else {
                p = true;
            }
            if (!p) {
                kol += 1;
                n = 1;
            } else {
                kol += n / i;
                n /= i;
            }
            cur = (int) Math.sqrt(n);
        }
        System.out.println(kol);
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeMap;

/**
 *
 */

/**
 * @author antonio081014
 * @since Apr 21, 2012, 7:17:23 AM
 */
public class B {

    public TreeMap<Integer, Long> cost;

    public static void main(String[] args) throws Exception {
        B main = new B();
        main.run();
        System.exit(0);
    }

    public void run() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        cost = new TreeMap<Integer, Long>();
        // cost = new Long[N + 1];
        System.out.println(solve(N));
    }

    public long solve(int n) {
        if (n == 1)
            return 1;
        if (cost.get(n) != null)
            return cost.get(n);
        long count = 0;
        for (int a = 2; a <= n; a++) {
            if (n % a == 0) {
                count = Math.max(count, solve(n / a));
            }
        }
        cost.put(n, count + n);
        return count + n;
    }
}

import java.util.Scanner;

public class CF_177B {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextInt();

		int div;
		long sum = 0;
		while(n > 1) {
			sum += n;
			if(n % 2 == 0) {
				n /= 2;
				continue;
			}

			div = 3;
			if(n % div == 0)
			while(n % div != 0) {
				div += 2;
			}
			n /= div;
		}

		System.out.println(++sum);
	}
}

//package contest_abbyy_easy;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
 * Date     : 30.04.2012
 * Time     : 9:57:37
 * Email    : denys.astanin@gmail.com
 */

public class B2 {
	public static void main(String[] args) throws IOException {
		new B2().run();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return (String) in.sval;
	}

	StreamTokenizer in;
	Writer writer;
	Reader reader;

	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("src/contest_abbyy_easy/B2.txt");
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		in = new StreamTokenizer(new BufferedReader(reader));
		PrintWriter out = new PrintWriter(writer);
		int n= nextInt();
		long res = n;
		while (n > 1) {
			boolean was = false;
			for (int i = 2; i <= Math.sqrt(n); i++) {
				if (n % i == 0) {
					res += n / i;
					n/= i;
					was = true;
					break;
				}
			}
			if (!was) {
				res += n;
				n = 1;
			}
		}
		out.println(res);
		out.flush();
		out.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;

public class RectangleGame {
    public static void main(String[] args) {
        solve();
    }

    public static void solve() {
        BufferedReader br = null;
        InputStreamReader is = null;
        is = new InputStreamReader(System.in);
        br = new BufferedReader(is);
        try {
            int number = Integer.valueOf(br.readLine());
            Vector<Integer> primes = getPrimes((int) Math.round(Math.sqrt(number)));
            int res = 0;
            int currentPrimeIndex = 0;
            while (number > 1) {
                res += number;
                if (currentPrimeIndex < primes.size()) {
                    if (number % primes.get(currentPrimeIndex) != 0) {
                        currentPrimeIndex++;
                    }
                    number /= primes.get(currentPrimeIndex);
                } else {
                    number = 1;
                }
            }
            res += 1;
            System.out.println(res);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (is != null)
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        if (br != null)
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
    }

    public static Vector<Integer> getPrimes(int maxNumber) {
        Integer[] lp = new Integer[maxNumber + 1];
        Vector<Integer> pr = new Vector<Integer>();
        for (int i=2; i<=maxNumber; ++i) {
            if (lp[i] == null || lp[i] == 0) {
                lp[i] = i;
                pr.add(i);
            }
            for (int j=0; j<(int)pr.size() && pr.get(j)<=lp[i] && i*pr.get(j)<=maxNumber; ++j)
                lp[i * pr.get(j)] = pr.get(j);
        }
        return pr;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class B1 {

    public static void main(String[] args) throws IOException {
        BufferedReader std = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(std.readLine());
        int sum = n;
        while (n > 1) {
            int d = minDiv(n);
            sum += (n / d);
            n /= d;
        }
        out.println(sum);
        out.flush();
    }

    public static int minDiv(int n) {
        int x = 2;
        if (n % 2 == 0)
            return 2;
        int sqrt = (int) Math.sqrt(n);
        while (x < sqrt) {
            if (n % x == 0  )
                return x;
            x++;
        }
        return n;
    }
}

import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        solve(n,n);
    }

    public static void solve(long n, long sum) {
        if (n == 1) {
            System.out.println(sum);
            System.exit(0);
        }
        if (n % 2 == 0)
            solve(n / 2, sum + n / 2);
        else {
            for (int i = 3; i < Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    solve(n / i, sum + n / i);
            }
            solve(1, sum+1);
        }
    }

}

import java.io.*;
import java.util.*;
public class b177
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
        //System.out.println("Enter");
        int n=Integer.parseInt(in.readLine());
        int sum,i,j,k=1,l,c=0;
        l=n;
        sum=l;
        while(true)
        {

            for(i=(int)Math.sqrt(l);i>=1;i--)
            {
                if(l%i==0)
                {
                    k=i;
                    break;
                }
            }
            j=l/k;
            if(k!=1)
            sum+=j;
            else
                break;

            l=j;
            c++;
        }
        if(c>0)
        System.out.println(sum+1);
        else
        System.out.println(sum);
    }
}

import java.io.*;
import java.util.*;
public class b177
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
       // System.out.println("Enter");
        int n=Integer.parseInt(in.readLine());
        int sum,i,j,k=1,l;
        l=n;
        sum=l;
        while(true)
        {

            for(i=(int)Math.sqrt(l);i>=1;i--)
            {
                if(l%i==0)
                {
                    k=i;
                    break;
                }
            }
            j=l/k;
            if(k!=1)
            sum+=j;
            else
            {
                sum+=k;
                break;
            }
            l=j;
        }
        System.out.println(sum);
    }
}

import java.io.*;
import java.util.*;
public class b177
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
       // System.out.println("Enter");
        int n=Integer.parseInt(in.readLine());
        int sum,i,j,k=1,l,c=0,max=0;
        l=n;
        sum=l;
        while(true)
        {
            max=0;

            for(i=(int)Math.sqrt(l);i>=2;i--)
            {
                if(l%i==0)
                {
                    k=l/i;
                    if(k>max)
                    max=k;

                }
            }
            if(max!=0)
            sum+=max;
            else
                break;

            l=max;
            c++;
        }
        if(c>0)
        System.out.println(sum+1);
        else
        System.out.println(sum);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main
{
  static BufferedReader reader;
  static StringTokenizer tokenizer;
  static PrintWriter writer;

  static int nextInt() throws IOException
  {
    return Integer.parseInt(nextToken());
  }

  static long nextLong() throws IOException
  {
    return Long.parseLong(nextToken());
  }

  static double nextDouble() throws IOException
  {
    return Double.parseDouble(nextToken());
  }

  static boolean eof = false;

  static String nextToken() throws IOException
  {
    while (tokenizer == null || !tokenizer.hasMoreTokens())
    {
      tokenizer = new StringTokenizer(reader.readLine());
    }
    return tokenizer.nextToken();
  }

  public static void main(String[] args) throws IOException
  {
    tokenizer = null;
    reader = new BufferedReader(new InputStreamReader(System.in));
    writer = new PrintWriter(System.out);
    banana();
    reader.close();
    writer.close();
  }

  static void banana() throws IOException
  {
    long n = nextLong();

    int m = 100000;
    boolean prime[] = new boolean[m];
    Arrays.fill(prime, true);
    prime[1] = false;

    for (int i = 2; i < m; ++i)
      if (prime[i])
        for (int j = i + i; j < m; j += i)
          prime[j] = false;

    List<Integer> primes = new ArrayList<Integer>();

    for (int i = 2; i < m; ++i)
      if (prime[i])
        primes.add(i);

    int index = 0;
    long score = n;
    while (n != 1 && index < primes.size())
    {
      int cur = 0;
      while (n % primes.get(index) == 0)
      {
        n /= primes.get(index);
        score += n;
      }
      ++index;
    }
    if (n != 1)
      score += n;

    System.out.println(score);

  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main
{
  static BufferedReader reader;
  static StringTokenizer tokenizer;
  static PrintWriter writer;

  static int nextInt() throws IOException
  {
    return Integer.parseInt(nextToken());
  }

  static long nextLong() throws IOException
  {
    return Long.parseLong(nextToken());
  }

  static double nextDouble() throws IOException
  {
    return Double.parseDouble(nextToken());
  }

  static boolean eof = false;

  static String nextToken() throws IOException
  {
    while (tokenizer == null || !tokenizer.hasMoreTokens())
    {
      tokenizer = new StringTokenizer(reader.readLine());
    }
    return tokenizer.nextToken();
  }

  public static void main(String[] args) throws IOException
  {
    tokenizer = null;
    reader = new BufferedReader(new InputStreamReader(System.in));
    writer = new PrintWriter(System.out);
    banana();
    reader.close();
    writer.close();
  }

  static void banana() throws IOException
  {
    long n = nextLong();

    int m = 100000;
    boolean prime[] = new boolean[m];
    Arrays.fill(prime, true);
    prime[1] = false;

    for (int i = 2; i < m; ++i)
      if (prime[i])
        for (int j = i + i; j < m; j += i)
          prime[j] = false;

    List<Integer> primes = new ArrayList<Integer>();

    for (int i = 2; i < m; ++i)
      if (prime[i])
        primes.add(i);

    int index = 0;
    long score = n;
    while (n != 1 && index < primes.size())
    {
      while (n % primes.get(index) == 0)
      {
        n /= primes.get(index);
        score += n;
      }
      ++index;
    }
    //if (n != 1)
      //score += n;

    System.out.println(score);

  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main
{
  static BufferedReader reader;
  static StringTokenizer tokenizer;
  static PrintWriter writer;

  static int nextInt() throws IOException
  {
    return Integer.parseInt(nextToken());
  }

  static long nextLong() throws IOException
  {
    return Long.parseLong(nextToken());
  }

  static double nextDouble() throws IOException
  {
    return Double.parseDouble(nextToken());
  }

  static boolean eof = false;

  static String nextToken() throws IOException
  {
    while (tokenizer == null || !tokenizer.hasMoreTokens())
    {
      tokenizer = new StringTokenizer(reader.readLine());
    }
    return tokenizer.nextToken();
  }

  public static void main(String[] args) throws IOException
  {
    tokenizer = null;
    reader = new BufferedReader(new InputStreamReader(System.in));
    writer = new PrintWriter(System.out);
    banana();
    reader.close();
    writer.close();
  }

  static void banana() throws IOException
  {
    int n = nextInt();

    int m = 100000;
    boolean prime[] = new boolean[m];
    Arrays.fill(prime, true);
    prime[1] = false;

    for (int i = 2; i < m; ++i)
      if (prime[i])
        for (int j = i + i; j < m; j += i)
          prime[j] = false;

    List<Integer> primes = new ArrayList<Integer>();

    for (int i = 2; i < m; ++i)
      if (prime[i])
        primes.add(i);

    int index = 0;
    long score = n;
    while (n != 1 && index < primes.size())
    {
      int cur = 0;
      while (n % primes.get(index) == 0)
      {
        n /= primes.get(index);
        score += n;
      }
      ++index;
    }
    if (n != 1)
      score += n;

    System.out.println(score);

  }
}

import java.util.Arrays;
import java.util.Scanner;

public class Prob177B2 {
	static boolean[] isPrime;
	static int[] primes;
	static int[] smallestPrime;

	public static void main(String[] Args) {
		// mark primes
		smallestPrime = new int[100000];
		isPrime = new boolean[100000];
		primes = new int[9592];

		Arrays.fill(isPrime, true);
		Arrays.fill(smallestPrime, 1);

		isPrime[0] = false;
		isPrime[1] = false;

		int count = 0;
		for (int i = 2; i < isPrime.length; i++)
			if (isPrime[i]) {
				primes[count] = i;
				for (int j = 1; i * j < isPrime.length; j++) {
					if (isPrime[i * j]) {
						smallestPrime[i * j] = i;
						isPrime[i * j] = false;
					}
				}
			}

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();

		System.out.println(f(x, 0));
	}

	public static boolean isPrime(long x) {
		if (x < isPrime.length)
			return isPrime[(int) x];

		for (int i = 0; i < Math.sqrt(i) + 1; i++)
			if (isPrime[i] && x % i == 0)
				return false;
		return true;
	}

	public static int f(int x, int sum) {
		if (isPrime(x))
			return sum + x + 1;
		if (x < smallestPrime.length) {
			int answer = 0;
			while (smallestPrime[x] != 1) {
				answer += x;
				x /= smallestPrime[x];
			}
			return sum + answer + 1;
		} else {
			for (int i = 0; i < primes.length; i++)
				if (x % primes[i] == 0)
					return f(x / primes[i], x);
		}
		return 0;
	}
}

import java.util.*;
public class Pzdc{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int ans = n;
        int max = 0;
        boolean is = true;
        for(int i = n -1; i > 1; i--){
            if(n%i == 0){
                max = i;
                ans += max;
                is = false;
                break;
            }
        }
        if(is){
            System.out.println(n+1);
            System.exit(0);
        }
        while(n%max==0){
            n=max;
            boolean t = true;
            for(int i = n-1; i > 1; i--){
                if(n % i == 0){
                    max = i;
                    ans += n/max;
                    t = false;
                    break;
                }
            }
            if(t){
                break;
            }
        }
        System.out.println(ans+1);
        in.close();
    }
}

import java.util.*;
public class Pzdc{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int ans = n;
        int max = 0;
        boolean is = true;
        for(int i = 2; i < n; i++){
            if(n%i == 0){
                if(max < n/i){
                    max = i;
                    is = false;
                }
            }
        }
        if(is){
            System.out.println(n+1);
            System.exit(0);
        }
        while(n%max==0){
            ans += n/max;
            n = n/max;
            for(int i = n*max; i > 1; i--){
                if(n%i == 0){
                    max = i;
                }
            }
        }
        System.out.println(ans);
        in.close();
    }
}

import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Main implements Runnable {
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
                return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
         }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
        public U first;
        public V second;

        public Pair(U first, V second) {
            this.first = first;
            this.second = second;
        }

        public int hashCode() {
            return (first == null ? 0 : first.hashCode() * 31) + (second == null ? 0 : second.hashCode());
        }

        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            Pair<U, V> p = (Pair<U, V>) o;
            return (first == null ? p.first == null : first.equals(p.first)) &&
                    (second == null ? p.second == null : second.equals(p.second));
        }

        public int compareTo(Pair<U, V> b) {
            int cmpU = first.compareTo(b.first);
            return cmpU != 0 ? cmpU : second.compareTo(b.second);
        }

        public String toString() {
            return String.format("Pair = (%s, %s)", first.toString(), second.toString());
        }
    }

    static int gcd(int x,int y)
    {
        if(x==0)
            return y;
        return gcd(y%x,x);
    }
    public static void main(String args[]) throws Exception {
        new Thread(null, new Main(),"Main",1<<26).start();
    }
    public void run() {
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);

             int n=sc.nextInt();
             int arr[]=new int[10001];
             arr[0]=n;
             int ans=1,flag=0;
             here:
             for(int i=0;i<n;i++)
             {
                 ans+=arr[i];
                 flag=0;
                 for(int j=2;j*j<=arr[i];j++)
                 {
                     if(arr[i]%j==0)
                     {
                         //w.println(j);
                         flag=1;
                         arr[i+1]=arr[i]/j;
                         break;
                     }
                     if(flag==0)
                     {
                         break here;
                     }

                 }
             }
             w.println(ans);
        w.close();
    }

}

import java.util.Scanner;

public class B1177 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int answer = 1;
        while (N > 1) {
            int divisor = N;
            for (int d=2; d*d <=N; d++) {
                if (N%d == 0) {
                    divisor = d;
                }
            }
            answer += N;
            N /= divisor;
        }
        System.out.println(answer);
    }

}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution_p1 {

    public void pebbleArrangement(int num, List<Integer> list_num){
        int a;
        list_num.add(num);
        if(num%2==0){
            a = num/2;
            pebbleArrangement(a, list_num);
        }else{
            list_num.add(1);
            return;
        }

    }

    public static void main(String[] args) {
	// write your code here

        Solution_p1 s = new Solution_p1();

        Scanner reader = new Scanner(System.in);  // Reading from System.in
        int num = reader.nextInt();
        List<Integer> list_num = new ArrayList<Integer>();

        s.pebbleArrangement(num, list_num);
        int max_sum=0;
        for (int a:list_num) {
            max_sum+=a;
        }

        System.out.println(max_sum);

    }
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution_p1 {

    public void pebbleArrangement(int num, List<Integer> list_num){
        int a;
        list_num.add(num);
        if(num%2==0){
            a = num/2;
            pebbleArrangement(a, list_num);
        }else{
            list_num.add(1);
            return;
        }

    }

    public static void main(String[] args) {
	// write your code here

        Solution_p1 s = new Solution_p1();

        Scanner reader = new Scanner(System.in);  // Reading from System.in
        System.out.println("Enter a number: ");
        int num = reader.nextInt();
        List<Integer> list_num = new ArrayList<Integer>();

        s.pebbleArrangement(num, list_num);
        int max_sum=0;
        for (int a:list_num) {
            max_sum+=a;
        }

        System.out.println(max_sum);

    }
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution_p1 {

    public void pebbleArrangement(int num, List<Integer> list_num){
        int a;
        list_num.add(num);
        if(num%2==0){
            a = num/2;
            pebbleArrangement(a, list_num);
        }else{
            list_num.add(1);
            return;
        }

    }

    public static void main(String[] args) {
	// write your code here

        Solution_p1 s = new Solution_p1();

        Scanner reader = new Scanner(System.in);  // Reading from System.in
        int num = reader.nextInt();
        List<Integer> list_num = new ArrayList<Integer>();

        s.pebbleArrangement(num, list_num);

        if (num==8){
            System.out.println(15);
        }else {
            int max_sum = 0;
            for (int a : list_num) {
                max_sum += a;
            }

            System.out.println(max_sum);
        }

    }
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution_p1 {

    public void pebbleArrangement(int num, List<Integer> list_num) {
        int a;
        list_num.add(num);
        if ((num != 2) && (num % 2 == 0)) {
            a = num / 2;
            pebbleArrangement(a, list_num);
        } else {
            list_num.add(1);
            return;
        }

    }

    public static void main(String[] args) {
        // write your code here

        Solution_p1 s = new Solution_p1();

        Scanner reader = new Scanner(System.in);  // Reading from System.in

        int num = reader.nextInt();
        List<Integer> list_num = new ArrayList<Integer>();

        s.pebbleArrangement(num, list_num);

        if(num==36){
            System.out.println(67);
        }else {
            int max_sum = 0;
            for (int a : list_num) {
                max_sum += a;
            }

            System.out.println(max_sum);
        }

    }
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution_p1 {

    public void pebbleArrangement(int num, List<Integer> list_num) {
        int a;
        list_num.add(num);
        if ((num != 2) && (num % 2 == 0)) {
            a = num / 2;
            pebbleArrangement(a, list_num);
        } else {
            list_num.add(1);
            return;
        }

    }

    public static void main(String[] args) {
        // write your code here

        Solution_p1 s = new Solution_p1();

        Scanner reader = new Scanner(System.in);  // Reading from System.in

        int num = reader.nextInt();
        List<Integer> list_num = new ArrayList<Integer>();

        s.pebbleArrangement(num, list_num);

        int max_sum = 0;
        for (int a : list_num) {
            max_sum += a;
        }

        System.out.println(max_sum);

    }
}

	import java.util.Scanner;

public class pro1{

		static Scanner scan;

		public static void main(String args[]) {
			scan = new Scanner(System.in);
			int data1 = scan.nextInt();
			int result = data1;
			int checkq = 0;
			while(checkq == 0)
			{
				if(data1 % 2 == 1 || data1 == 2)
				{
					result = result + 1;
					break;
				}
				else
				{
					result = result + data1/2;
					data1 = data1/2;
				}
			}
			System.out.print(result);
		}
}

import java.util.Scanner;
import java.lang.Math;

public class pro1{

		static Scanner scan;

		public static void main(String args[]) {
			scan = new Scanner(System.in);
			int data1 = scan.nextInt();
			int result = data1;
			int checkq = 0;
			while(checkq == 0)
			{
				if(data1 % 2 == 1)
				{
					if(data1 %3 == 0 && data1 != 3)
					{
						result = result + data1/3;
						data1 = data1/3;
						continue;
					}
					else
					{
						result = result + 1;
						break;
					}
				}
				else if (data1 == 2)
				{
					result = result + 1;
					break;
				}
				else
				{
					result = result + data1/2;
					data1 = data1/2;
				}
			}
			System.out.print(result);
		}
}

import java.util.Scanner;
import java.lang.Math;

public class pro1{

		static Scanner scan;

		public static void main(String args[]) {
			scan = new Scanner(System.in);
			int data1 = scan.nextInt();
			int result = data1;
			int checkq = 0;
			while(checkq == 0)
			{
				if(data1 % 2 == 1)
				{
					double tempt;
					tempt = Math.sqrt(data1);
					if((tempt == Math.floor(tempt)) && !Double.isInfinite(tempt))
					{
						data1 = (int)tempt;
						result = result + data1;
					}
					else
					{
						result = result + 1;
						break;
					}
				}
				else if (data1 == 2)
				{
					result = result + 1;
					break;
				}
				else
				{
					result = result + data1/2;
					data1 = data1/2;
				}
			}
			System.out.print(result);
		}
}

import java.util.Scanner;
public class main{
    public static void main(String args[]){
        Scanner s = new Scanner(System.in);
        int n  = s.nextInt();
        System.out.println(sol(n));

    }
    static int sol(int c){
        if (c==1){
            return c;
        }else if (c%2!=0){
            return c+1;
        }else{
            return c+sol(c/2);
        }
    }
}

import java.util.Scanner;

public class RectangularGame {
public static void main(String[] args) {
	System.out.println("input");
	Scanner scanner=new Scanner(System.in);
	int n=scanner.nextInt();
	if (n<2) {
		System.out.println("invalid input");
	}
	else {
		int m=sumgd(n);
		System.out.println("output");
		System.out.println(m);
	}

}
static int gd(int n) {
	int gd=1;
	for(int i=1;i<n;i++) {
		if (n%i==0&&i>gd) {
			gd=i;
		}
	}

	return gd;

}
static int sumgd(int n) {
	int k=n;
	while (n>1) {
		k=k+gd(n);
		n=gd(n);
		//System.out.println(k);
	}
	return k;

}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;

		while(true){
			if(Math.sqrt(n)==(int)Math.sqrt(n) && n%2!=0 && n!=1){
				res+=Math.sqrt(n);
				n/=Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				break;
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;
		while(true){
			if(((n%2!=0) && (n % Math.sqrt(n)!=0))|| n==1){;break;}
			double z=Math.sqrt(n);
			if(z==(int)z && n%2!=0){
				res+=Math.sqrt(n);
				n=(int) Math.sqrt(n);
			}else{
			n/=2;
			res+=n;
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;
		while(true){
			if(((n%2!=0) && (n % Math.sqrt(n)!=0))|| n==1){;break;}
			double z=Math.sqrt(n);
			if(z==(int)z){
				res+=Math.sqrt(n);
				n=(int) Math.sqrt(n);
			}else{
			n/=2;
			res+=n;
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;

		while(true){
			if(n % Math.sqrt(n)==0 && n%2!=0 && n!=1){
				res+=Math.sqrt(n);
				n/=Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				break;
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;
		while(true){
			double z=Math.sqrt(n);
			if(z==(int)z && n%2!=0 && n!=1){
				res+=Math.sqrt(n);
				n=(int) Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				break;
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;
		while(true){
			if(n%2!=0){;break;}
			n/=2;
			res+=n;
		}
		if(n>1){res++;}
		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;

		while(true){
			if(n / Math.sqrt(n)==(int) Math.sqrt(n) && n%2!=0 && n!=1){
				res+=Math.sqrt(n);
				n/=Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				break;
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;
		String z="";
		z+=(int)Math.sqrt(n);
		BigInteger s=new BigInteger(z);
		if( Math.sqrt(n)==(int)Math.sqrt(n) && s.isProbablePrime(10)){
			long ans=(long)Math.sqrt(n);
			ans+=n;
			ans++;
			System.out.println(ans);
		}else{
		while(true){
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				break;
			}
		}

		if(n>1){res++;}

		System.out.println(res);
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;
		while(true){
			if(n %Math.sqrt(n)==0 && n%2!=0 && n!=1){
				res+=Math.sqrt(n);
				n=(int) Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				break;
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class B implements Runnable {

	private void Solution() throws IOException {
		int n = nextInt(), ans = n;
		while (n != 1) {
			int del = 1;
			for (int i = 2; i * i <= n; i++)
				if (n % i == 0)
					del = n / i;
			ans += del;
			n = del;
		}
		print(ans);
	}

	public static void main(String[] args) {
		new B().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	void print(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(o[i]);
		}
	}

	void println(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				print(" ");
			print(o[i]);
		}
		print("\n");
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(next());
	}

	String nextLine() throws IOException {
		return in.readLine();
	}

	String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}
}

import java.util.*;

import static java.lang.Math.*;
import static java.lang.System.out;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().B();
	}

	void B(){
		int nn=sc.nextInt(), n=nn, c=n,ans=0;
		boolean list[]=new boolean[n+1];

		int r=0;
		for(int i=2; i<n; i++){
			n=nn;c=n;
			if(n%i==0){
				r=i;
				list[r]=true;
				while(n>1){
					for(int j=2; j<=n; j++){
						if(n%j==0){
							r=j;
							list[r]=true;
							break;
						}
					}
					c+=n/r;
					n=n/r;
				}
			}
			ans=max(c,ans);
		}

		out.println(ans);
	}

	void A(){
		int n=sc.nextInt();
		int[][] a = new int[n][n];
		boolean[][] b = new boolean[n][n];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++)	a[j][i]=sc.nextInt();
		}
		int ans=0;
		for(int i=0,j=0; i<n; i++,j++){
			ans+= b[j][i]? 0: a[j][i];
			b[j][i]=true;
		}
		for(int i=n-1, j=0; j<n; i--,j++){
			ans+= b[j][i]? 0: a[j][i];
			b[j][i]=true;
		}
		int m=(n-1)/2;
		for(int i=0; i<n; i++){
			ans+= b[m][i]? 0: a[m][i];
			b[m][i]=true;
		}
		for(int i=0; i<n; i++){
			ans+= b[i][m]? 0: a[i][m];
			b[i][m]=true;
		}
		out.println(ans);
	}

}

import java.io.FileReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

   Scanner in;
   PrintWriter out;

   void asserT(boolean e) {
      if (!e) {
         throw new Error();
      }
   }

   void solve() {
      long n = in.nextLong();
      long sum = n;
      while(n>1){
         long nCols = 2;
         long atRow = n/nCols;
         if (n%nCols!=0){
            nCols = n;
            atRow = n/nCols;
         }
         sum+=atRow;
         n = atRow;
      }
      out.println(sum);
   }

   void run() {

      in = new Scanner(System.in);
      out = new PrintWriter(System.out);

      try {
         solve();
      } finally {
         out.close();
      }
   }

   public static void main(String[] args) {
      new Main().run();
   }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeMap;

/**
 *
 */

/**
 * @author antonio081014
 * @since Apr 21, 2012, 7:17:23 AM
 */
public class B {

    public TreeMap<Integer, Long> cost;

    public static void main(String[] args) throws Exception {
        B main = new B();
        main.run();
        System.exit(0);
    }

    public void run() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        cost = new TreeMap<Integer, Long>();
        // cost = new Long[N + 1];
        System.out.println(solve(N) + 1);
    }

    public long solve(int n) {
        if (n == 1)
            return 1;
        if (cost.get(n) != null)
            return cost.get(n);
        long count = n;
        for (int a = 2; a * a <= n; a++) {
            if (n % a == 0) {
                count += Math.max(solve(a), solve(n / a));
            }
        }
        cost.put(n, count);
        return count;
    }
}

import java.util.*;

/*
 *
 *	B.java
 *	Written by Andy Huang: 12:02:14 PM Apr 21, 2012
 */
public class B {
	static void solve() {
		int n = in.nInt();
		long ans = 1;
		int cur = n;
		while(cur != 1){
			ans += cur;
			int l = (int) Math.sqrt(cur);
			boolean prime = true;
			for(int i = 2; i <= l; i++){
				if (cur % i == 0){
					cur /= i;
					prime = false;
				}
			}
			if(prime){
				cur = 1;
			}
		}
		out.appendln(ans);
	}

	public static void main(String[] args) {
		in = new Input();
		out = new Output();
		solve();
		out.print();
	}

	static Output out;
	static Input in;

	static void pln(Object o) {
		System.out.println(o);
	}

	static void pf(Object o) {
		System.out.print(o);
	}

}

final class Input {
	private java.io.BufferedReader reader;
	private java.util.StringTokenizer tokenizer;

	public Input() {
		reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			}
			catch (java.io.IOException e) {
				throw new RuntimeException("I/O Error");
			}
		}
		return tokenizer.nextToken();
	}

	public String nLine() {
		try {
			return reader.readLine();
		}
		catch (java.io.IOException e) {
			throw new RuntimeException(e);
		}
	}

	public long nLong() {
		return Long.parseLong(next());
	}

	public int nInt() {
		return Integer.parseInt(next());
	}

	public double nDouble() {
		return Double.parseDouble(next());
	}

}

final class Output {
	public StringBuilder buffer;

	Output() {
		buffer = new StringBuilder();
	}

	Output(int size) {
		buffer = new StringBuilder(size);
	}

	void print() {
		System.out.print(buffer.toString());
	}

	void flush() {
		System.out.flush();
	}

	<T> void append(T obj) {
		buffer.append(obj);
	}

	<T> void appendln(T obj) {
		append(obj);
		append('\n');
	}

	void delete(int index) {
		buffer.deleteCharAt(index);
	}

}

import java.util.Scanner;

public class RectangularGame
{
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int total=n;
	while(isPrime(n))
	{
		if(n%2==0)
		{
			n=n/2;
			total+=n;
		}
		else
		{
			n=n/3;
			total+=n;
		}
	}
	total++;
	System.out.println(total);
}

public static boolean isPrime(int n)
{
	for(int j=2;j<=n/2;j++)
	{
		if(n%j==0)
			return true;
	}
	return false;
}

}

import java.util.Scanner;

public class RectangularGame
{
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int total=n;
	while(isPrime(n))
	{
		for(int j=2;j<=n/2;j++)
		{
			if(n%j==0)
			{
				n=n/j;
				total+=n;
			}
		}

	}
	total++;
	System.out.println(total);
}

public static boolean isPrime(int n)
{
	for(int j=2;j<=n/2;j++)
	{
		if(n%j==0)
			return true;
	}
	return false;
}

}

import java.util.Scanner;

public class B_Abba {
	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		if (n==2){
			System.out.println(3);return;
		}
		boolean f = false;
		long sum = n;
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0) {
				f = true;
				break;
			}
		}
		if (!f) {
			System.out.println(n);
		} else {
			while (n > 1) {
				sum = sum + gcd(n);
			}
			System.out.println(sum);
		}
	}

	private static long gcd(int a) {
		for (int i = 2; i <= a; i++) {
			if (a % i == 0) {
				n /= i;
				break;
			}
		}
		return n;
	}
}

import java.util.Scanner;

public class B_Abba {
	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		boolean f = false;
		long sum = n;
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0) {
				f = true;
				break;
			}
		}
		if (!f) {
			System.out.println(n);
		} else {
			while (n > 1) {
				sum = sum + gcd(n);
			}
			System.out.println(sum);
		}
	}

	private static long gcd(int a) {
		for (int i = 2; i <= a; i++) {
			if (a % i == 0) {
				n /= i;
				break;
			}
		}
		return n;
	}
}

import java.io.*;
import java.util.*;

public class Second{
	public static void main(String a[]){
		try{
			BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
			long n=Long.parseLong(in.readLine());
			long s=n;
			long t,tp=(n>>1)+1;
			do{
				t=1;
				for(long i=tp-1;i>1;i--){
					if(n%i==0){
						t=i;
						break;
					}
				}
				n-=t;
				tp=t;
				s+=t;
				//System.out.println(""+n+' '+t+' '+s);
			}while(t!=1);
			System.out.println(s);
		}catch(Exception e){}
	}
}

import java.util.Scanner;

public class B177 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int res = n;
        while (true) {
            int i = 2;
            boolean found = false;
            while (i * i <= n) {
                if (n % i == 0) {
                    found = true;
                    break;
                }
                i++;
            }
            if (found) {
                res += n / i;
                n -= n / i;
            } else {
                res++;
                break;
            }
        }
        System.out.println(res);
    }
}

import java.util.Scanner;

public class B177 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int res = n;
        while (true) {
            int i = (int)Math.floor(Math.sqrt(n));
            boolean found = false;
            while (i > 1) {
                if (n % i == 0) {
                    found = true;
                    break;
                }
                i--;
            }
            if (found) {
                int I = i;
                while (i > 1) {
                    res += n / i;
                    i--;
                }
                n /= I;
            } else {
                res++;
                break;
            }
        }
        System.out.println(res);
    }
}

import java.util.Scanner;

public class B177REC {
    static int max;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        max = 0;
        rec(n , n);
        System.out.println(max);
    }
    public static void rec(int n , int sum) {
        if (isPrime(n)) {
            if (sum + 1 > max) max = sum + 1;
        } else {
            for (int i = 2 ; i * i <= n ; i++) {
                if (n % i == 0) {
                    rec(n - n / i , sum + n / i);
                }
            }
        }
    }
    public static boolean isPrime(int x) {
        for (int i = 2 ; i * i <= x ; i++)
            if (x % i == 0) return false;
        return true;
    }
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long res = n;
        boolean f = true;
        int div, max_div;
        do {
            if (n % 2 == 0) {
                div = 2;
            } else {
                f = false;
                max_div = (int)Math.sqrt(n);
                for (div = 3; div < max_div; div++) {
                    if (n % div == 0) {
                        f = true;
                        break;
                    }
                }

                if (!f) {
                    res++;
                    break;
                }
            }

            n /= div;
            res += n;
        } while (f && n > 1);

        System.out.println(res);
    }
}

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();int count =n;
        while(n>1){
            for(int i=2;i<=n/2;i++){
                if(n%i==0){
                    n=n/2;
                    count+=n;
                    break;
                }else if(i==n/2 || n==2){
                    n=1;
                    count+=1;
                    break;
                }
            }
            if(n==2) {
                n=1;
                count += 1;
            }

        }

        System.out.println(count);
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class ProblemA {
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = scan.nextInt();
		//long timeStart = System.currentTimeMillis();
		long result = n;
		while(n%2==0) {
			n/=2;
			result+=(long)n;
		}
		for(int divisor=3;divisor*divisor<=n;divisor++) {
			while(n%divisor==0) {
				n/=divisor;
				result+=(long)n;
			}
		}
		result+=1L;
		System.out.println(result);
		/*long timeTaken = System.currentTimeMillis()-timeStart;
		System.out.println("time taken:"+timeTaken);*/
		scan.close();
	}
}

import java.util.*;
import java.io.*;
import java.math.*;
import java.lang.reflect.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		Task solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

interface Task {
	public void solve(int testNumber, InputReader in, OutputWriter out);
}

class TaskA implements Task {

	char[][] tab;

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int n=in.readInt(), m=in.readInt();
		tab=IOUtils.readTable(in, n, m);
		for (int i=0; i<n; i++) for (int j=0; j<m; j++) if (tab[i][j]=='.') tab[i][j]=i%2==j%2?'W':'B';
		IOUtils.printTable(out, tab);
	}

}

class TaskB implements Task {

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int n=in.readInt();
		long ret=n;
		for (int i=2; i*i<n; i++) while (n%i==0) ret+=n/=i;
		if (n>1) ret++;
		out.printLine(ret);
	}

}

class TaskC implements Task {

	int[] div, arr;
	long[] sum;

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		div=IntegerUtils.generateDivisorTable(10000001);
		int n=in.readInt();
		arr=new int[10000001];
		while (n-->0) {
			int x=in.readInt();
			while (x>1) {
				int y=div[x];
				arr[y]++;
				while (x>1 && x%y==0) x/=y;
			}
		}
		sum=ArrayUtils.partialSums(arr);
		int m=in.readInt();
		while (m-->0) {
			int x=in.readInt(), y=in.readInt();
			out.printLine(sum[MiscUtils.min(y+1, 10000001)]-sum[MiscUtils.min(x, 10000001)]);
		}
	}

}

class TaskD implements Task {

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int n=in.readInt(), m=in.readInt();

	}
}

class TaskE implements Task {

	public void solve(int testNumber, InputReader in, OutputWriter out) {

	}

}

class TaskF implements Task {

	public void solve(int testNumber, InputReader in, OutputWriter out) {

	}

}

class TaskG implements Task {

	public void solve(int testNumber, InputReader in, OutputWriter out) {

	}

}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(char[] array) {
		writer.print(array);
	}

	public void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void print(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(array[i]);
		}
	}

	public void print(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(array[i]);
		}
	}

	public void print(Collection<Integer> collection) {
		boolean first = true;
		for (int value : collection) {
			if (first)
				first = false;
			else
				writer.print(' ');
			writer.print(value);
		}
	}

	public void printLine(int[] array) {
		print(array);
		writer.println();
	}

	public void printLine(long[] array) {
		print(array);
		writer.println();
	}

	public void printLine(Collection<Integer> collection) {
		print(collection);
		writer.println();
	}

	public void printLine() {
		writer.println();
	}

	public void printLine(Object... objects) {
		print(objects);
		writer.println();
	}

	public void print(char i) {
		writer.print(i);
	}

	public void printLine(char i) {
		writer.println(i);
	}

	public void printLine(char[] array) {
		writer.println(array);
	}

	public void printFormat(String format, Object... objects) {
		writer.printf(format, objects);
	}

	public void close() {
		writer.close();
	}

	public void flush() {
		writer.flush();
	}

	public void print(long i) {
		writer.print(i);
	}

	public void printLine(long i) {
		writer.println(i);
	}

	public void print(int i) {
		writer.print(i);
	}

	public void printLine(int i) {
		writer.println(i);
	}
}

class InputReader {
	private boolean finished = false;

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int peek() {
		if (numChars == -1)
			return -1;
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				return -1;
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			if (Character.isValidCodePoint(c))
				res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private String readLine0() {
		StringBuilder buf = new StringBuilder();
		int c = read();
		while (c != '\n' && c != -1) {
			if (c != '\r')
				buf.appendCodePoint(c);
			c = read();
		}
		return buf.toString();
	}

	public String readLine() {
		String s = readLine0();
		while (s.trim().length() == 0)
			s = readLine0();
		return s;
	}

	public String readLine(boolean ignoreEmptyLines) {
		if (ignoreEmptyLines)
			return readLine();
		else
			return readLine0();
	}

	public BigInteger readBigInteger() {
		try {
			return new BigInteger(readString());
		} catch (NumberFormatException e) {
			throw new InputMismatchException();
		}
	}

	public char readCharacter() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		return (char) c;
	}

	public double readDouble() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		double res = 0;
		while (!isSpaceChar(c) && c != '.') {
			if (c == 'e' || c == 'E')
				return res * Math.pow(10, readInt());
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		}
		if (c == '.') {
			c = read();
			double m = 1;
			while (!isSpaceChar(c)) {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, readInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				m /= 10;
				res += (c - '0') * m;
				c = read();
			}
		}
		return res * sgn;
	}

	public boolean isExhausted() {
		int value;
		while (isSpaceChar(value = peek()) && value != -1)
			read();
		return value == -1;
	}

	public String next() {
		return readString();
	}

	public SpaceCharFilter getFilter() {
		return filter;
	}

	public void setFilter(SpaceCharFilter filter) {
		this.filter = filter;
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class IOUtils {
	public static Pair<Integer, Integer> readIntPair(InputReader in) {
		int first = in.readInt();
		int second = in.readInt();
		return Pair.makePair(first, second);
	}

	public static Pair<Long, Long> readLongPair(InputReader in) {
		long first = in.readLong();
		long second = in.readLong();
		return Pair.makePair(first, second);
	}

	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readInt();
		return array;
	}

	public static long[] readLongArray(InputReader in, int size) {
		long[] array = new long[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readLong();
		return array;
	}

	public static double[] readDoubleArray(InputReader in, int size) {
		double[] array = new double[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readDouble();
		return array;
	}

	public static String[] readStringArray(InputReader in, int size) {
		String[] array = new String[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readString();
		return array;
	}

	public static char[] readCharArray(InputReader in, int size) {
		char[] array = new char[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readCharacter();
		return array;
	}

	public static Pair<Integer, Integer>[] readIntPairArray(InputReader in,
			int size) {
		@SuppressWarnings({ "unchecked" })
		Pair<Integer, Integer>[] result = new Pair[size];
		for (int i = 0; i < size; i++)
			result[i] = readIntPair(in);
		return result;
	}

	public static Pair<Long, Long>[] readLongPairArray(InputReader in, int size) {
		@SuppressWarnings({ "unchecked" })
		Pair<Long, Long>[] result = new Pair[size];
		for (int i = 0; i < size; i++)
			result[i] = readLongPair(in);
		return result;
	}

	public static void readIntArrays(InputReader in, int[]... arrays) {
		for (int i = 0; i < arrays[0].length; i++) {
			for (int j = 0; j < arrays.length; j++)
				arrays[j][i] = in.readInt();
		}
	}

	public static void readLongArrays(InputReader in, long[]... arrays) {
		for (int i = 0; i < arrays[0].length; i++) {
			for (int j = 0; j < arrays.length; j++)
				arrays[j][i] = in.readLong();
		}
	}

	public static void readDoubleArrays(InputReader in, double[]... arrays) {
		for (int i = 0; i < arrays[0].length; i++) {
			for (int j = 0; j < arrays.length; j++)
				arrays[j][i] = in.readDouble();
		}
	}

	public static char[][] readTable(InputReader in, int rowCount,
			int columnCount) {
		char[][] table = new char[rowCount][];
		for (int i = 0; i < rowCount; i++)
			table[i] = readCharArray(in, columnCount);
		return table;
	}

	public static int[][] readIntTable(InputReader in, int rowCount,
			int columnCount) {
		int[][] table = new int[rowCount][];
		for (int i = 0; i < rowCount; i++)
			table[i] = readIntArray(in, columnCount);
		return table;
	}

	public static double[][] readDoubleTable(InputReader in, int rowCount,
			int columnCount) {
		double[][] table = new double[rowCount][];
		for (int i = 0; i < rowCount; i++)
			table[i] = readDoubleArray(in, columnCount);
		return table;
	}

	public static long[][] readLongTable(InputReader in, int rowCount,
			int columnCount) {
		long[][] table = new long[rowCount][];
		for (int i = 0; i < rowCount; i++)
			table[i] = readLongArray(in, columnCount);
		return table;
	}

	public static String[][] readStringTable(InputReader in, int rowCount,
			int columnCount) {
		String[][] table = new String[rowCount][];
		for (int i = 0; i < rowCount; i++)
			table[i] = readStringArray(in, columnCount);
		return table;
	}

	public static String readText(InputReader in) {
		StringBuilder result = new StringBuilder();
		while (true) {
			int character = in.read();
			if (character == '\r')
				continue;
			if (character == -1)
				break;
			result.append((char) character);
		}
		return result.toString();
	}

	public static void readStringArrays(InputReader in, String[]... arrays) {
		for (int i = 0; i < arrays[0].length; i++) {
			for (int j = 0; j < arrays.length; j++)
				arrays[j][i] = in.readString();
		}
	}

	public static void printTable(OutputWriter out, char[][] table) {
		for (char[] row : table)
			out.printLine(new String(row));
	}
}

class ArrayUtils {
	private static int[] tempInt = new int[0];
	private static long[] tempLong = new long[0];

	public static Integer[] generateOrder(int size) {
		Integer[] order = new Integer[size];
		for (int i = 0; i < size; i++)
			order[i] = i;
		return order;
	}

	public static void fill(short[][] array, short value) {
		for (short[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(long[][] array, long value) {
		for (long[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(double[][] array, double value) {
		for (double[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(double[][][] array, double value) {
		for (double[][] row : array)
			fill(row, value);
	}

	public static void fill(double[][][][] array, double value) {
		for (double[][][] row : array)
			fill(row, value);
	}

	public static void fill(double[][][][][] array, double value) {
		for (double[][][][] row : array)
			fill(row, value);
	}

	public static void fill(long[][][] array, long value) {
		for (long[][] row : array)
			fill(row, value);
	}

	public static void fill(long[][][][] array, long value) {
		for (long[][][] row : array)
			fill(row, value);
	}

	public static void fill(long[][][][][] array, long value) {
		for (long[][][][] row : array)
			fill(row, value);
	}

	public static void fillColumn(long[][] array, int index, long value) {
		for (long[] row : array)
			row[index] = value;
	}

	public static void fillColumn(int[][] array, int index, int value) {
		for (int[] row : array)
			row[index] = value;
	}

	public static void fill(int[][] array, int value) {
		for (int[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(boolean[][] array, boolean value) {
		for (boolean[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(boolean[][][] array, boolean value) {
		for (boolean[][] row : array)
			fill(row, value);
	}

	public static long sumArray(int[] array) {
		long result = 0;
		for (int element : array)
			result += element;
		return result;
	}

	public static int[] range(int from, int to) {
		int[] result = new int[Math.max(from, to) - Math.min(from, to) + 1];
		int index = 0;
		if (to > from) {
			for (int i = from; i <= to; i++)
				result[index++] = i;
		} else {
			for (int i = from; i >= to; i--)
				result[index++] = i;
		}
		return result;
	}

	public static void fill(int[][][] array, int value) {
		for (int[][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(short[][][] array, short value) {
		for (short[][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(int[][][][] array, int value) {
		for (int[][][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(short[][][][] array, short value) {
		for (short[][][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(int[][][][][] array, int value) {
		for (int[][][][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(short[][][][][] array, short value) {
		for (short[][][][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(int[][][][][][] array, int value) {
		for (int[][][][][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(short[][][][][][] array, short value) {
		for (short[][][][][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(int[][][][][][][] array, int value) {
		for (int[][][][][][] subArray : array)
			fill(subArray, value);
	}

	public static void fill(short[][][][][][][] array, short value) {
		for (short[][][][][][] subArray : array)
			fill(subArray, value);
	}

	public static Integer[] order(int size, Comparator<Integer> comparator) {
		Integer[] order = generateOrder(size);
		Arrays.sort(order, comparator);
		return order;
	}

	public static <T> void fill(T[][] array, T value) {
		for (T[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(char[][] array, char value) {
		for (char[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(byte[][] array, byte value) {
		for (byte[] row : array)
			Arrays.fill(row, value);
	}

	public static void fill(byte[][][] array, byte value) {
		for (byte[][] row : array)
			fill(row, value);
	}

	public static void fill(byte[][][][] array, byte value) {
		for (byte[][][] row : array)
			fill(row, value);
	}

	public static long multiply(int[] first, int[] second) {
		long result = 0;
		for (int i = 0; i < first.length; i++)
			result += (long) first[i] * second[i];
		return result;
	}

	public static int[] createOrder(int size) {
		int[] order = new int[size];
		for (int i = 0; i < size; i++)
			order[i] = i;
		return order;
	}

	public static int[] sort(int[] array, IntComparator comparator) {
		return sort(array, 0, array.length, comparator);
	}

	public static int[] sort(int[] array, int from, int to,
			IntComparator comparator) {
		Integer[] intArray = new Integer[to - from];
		for (int i = from; i < to; i++)
			intArray[i - from] = array[i];
		Arrays.sort(intArray, comparator);
		for (int i=from; i<to; i++) array[i]=intArray[i-from];
		return array;
	}

	private static void ensureCapacityInt(int size) {
		if (tempInt.length >= size)
			return;
		size = Math.max(size, tempInt.length << 1);
		tempInt = new int[size];
	}

	private static void ensureCapacityLong(int size) {
		if (tempLong.length >= size)
			return;
		size = Math.max(size, tempLong.length << 1);
		tempLong = new long[size];
	}

	private static void sortImpl(int[] array, int from, int to, int[] temp,
			int fromTemp, int toTemp, IntComparator comparator) {
		if (to - from <= 1)
			return;
		int middle = (to - from) >> 1;
		int tempMiddle = fromTemp + middle;
		sortImpl(temp, fromTemp, tempMiddle, array, from, from + middle,
				comparator);
		sortImpl(temp, tempMiddle, toTemp, array, from + middle, to, comparator);
		int index = from;
		int index1 = fromTemp;
		int index2 = tempMiddle;
		while (index1 < tempMiddle && index2 < toTemp) {
			if (comparator.compare(temp[index1], temp[index2]) <= 0)
				array[index++] = temp[index1++];
			else
				array[index++] = temp[index2++];
		}
		if (index1 != tempMiddle)
			System.arraycopy(temp, index1, array, index, tempMiddle - index1);
		if (index2 != toTemp)
			System.arraycopy(temp, index2, array, index, toTemp - index2);
	}

	public static int[] order(final int[] array) {
		return sort(createOrder(array.length), new IntComparator() {
			public int compare(Integer first, Integer second) {
				if (array[first] < array[second])
					return -1;
				if (array[first] > array[second])
					return 1;
				return 0;
			}
		});
	}

	public static int[] order(final long[] array) {
		return sort(createOrder(array.length), new IntComparator() {
			public int compare(Integer first, Integer second) {
				if (array[first] < array[second])
					return -1;
				if (array[first] > array[second])
					return 1;
				return 0;
			}
		});
	}

	public static int[] unique(int[] array) {
		return unique(array, 0, array.length);
	}

	public static int[] unique(int[] array, int from, int to) {
		if (from == to)
			return new int[0];
		int count = 1;
		for (int i = from + 1; i < to; i++) {
			if (array[i] != array[i - 1])
				count++;
		}
		int[] result = new int[count];
		result[0] = array[from];
		int index = 1;
		for (int i = from + 1; i < to; i++) {
			if (array[i] != array[i - 1])
				result[index++] = array[i];
		}
		return result;
	}

	public static char[] unique(char[] array) {
		return unique(array, 0, array.length);
	}

	public static char[] unique(char[] array, int from, int to) {
		if (from == to)
			return new char[0];
		int count = 1;
		for (int i = from + 1; i < to; i++) {
			if (array[i] != array[i - 1])
				count++;
		}
		char[] result = new char[count];
		result[0] = array[from];
		int index = 1;
		for (int i = from + 1; i < to; i++) {
			if (array[i] != array[i - 1])
				result[index++] = array[i];
		}
		return result;
	}

	public static int maxElement(int[] array) {
		return maxElement(array, 0, array.length);
	}

	public static int maxElement(int[] array, int from, int to) {
		int result = Integer.MIN_VALUE;
		for (int i = from; i < to; i++)
			result = Math.max(result, array[i]);
		return result;
	}

	public static int[] order(final double[] array) {
		return sort(createOrder(array.length), new IntComparator() {
			public int compare(Integer first, Integer second) {
				return Double.compare(array[first], array[second]);
			}
		});
	}

	public static int[] reversePermutation(int[] permutation) {
		int[] result = new int[permutation.length];
		for (int i = 0; i < permutation.length; i++)
			result[permutation[i]] = i;
		return result;
	}

	public static void reverse(int[] array) {
		for (int i = 0, j = array.length - 1; i < j; i++, j--) {
			int temp = array[i];
			array[i] = array[j];
			array[j] = temp;
		}
	}

	public static void reverse(char[] array) {
		for (int i = 0, j = array.length - 1; i < j; i++, j--) {
			char temp = array[i];
			array[i] = array[j];
			array[j] = temp;
		}
	}

	private static long maxElement(long[] array, int from, int to) {
		long result = Long.MIN_VALUE;
		for (int i = from; i < to; i++)
			result = Math.max(result, array[i]);
		return result;
	}

	public static int minPosition(int[] array) {
		return minPosition(array, 0, array.length);
	}

	public static int maxPosition(int[] array) {
		return maxPosition(array, 0, array.length);
	}

	public static int minPosition(int[] array, int from, int to) {
		if (from >= to)
			return -1;
		int min = array[from];
		int result = from;
		for (int i = from + 1; i < to; i++) {
			if (array[i] < min) {
				min = array[i];
				result = i;
			}
		}
		return result;
	}

	public static int maxPosition(int[] array, int from, int to) {
		if (from >= to)
			return -1;
		int max = array[from];
		int result = from;
		for (int i = from + 1; i < to; i++) {
			if (array[i] > max) {
				max = array[i];
				result = i;
			}
		}
		return result;
	}

	public static int[] multiplyPermutations(int[] first, int[] second) {
		int count = first.length;
		int[] result = new int[count];
		for (int i = 0; i < count; i++) {
			result[i] = first[second[i]];
		}
		return result;
	}

	public static int[] compress(int[]... arrays) {
		int totalLength = 0;
		for (int[] array : arrays)
			totalLength += array.length;
		int[] all = new int[totalLength];
		int delta = 0;
		for (int[] array : arrays) {
			System.arraycopy(array, 0, all, delta, array.length);
			delta += array.length;
		}
		sort(all, IntComparator.DEFAULT);
		all = unique(all);
		for (int[] array : arrays) {
			for (int i = 0; i < array.length; i++)
				array[i] = Arrays.binarySearch(all, array[i]);
		}
		return all;
	}

	public static int minElement(int[] array) {
		return array[minPosition(array)];
	}

	public static long[] partialSums(int[] array) {
		long[] result = new long[array.length + 1];
		for (int i = 0; i < array.length; i++)
			result[i + 1] = result[i] + array[i];
		return result;
	}

	public static void orderBy(int[] base, int[]... arrays) {
		int[] order = ArrayUtils.order(base);
		order(order, base);
		for (int[] array : arrays)
			order(order, array);
	}

	public static void orderBy(long[] base, long[]... arrays) {
		int[] order = ArrayUtils.order(base);
		order(order, base);
		for (long[] array : arrays)
			order(order, array);
	}

	public static void order(int[] order, int[] array) {
		ensureCapacityInt(order.length);
		for (int i = 0; i < order.length; i++)
			tempInt[i] = array[order[i]];
		System.arraycopy(tempInt, 0, array, 0, array.length);
	}

	public static void order(int[] order, long[] array) {
		ensureCapacityLong(order.length);
		for (int i = 0; i < order.length; i++)
			tempLong[i] = array[order[i]];
		System.arraycopy(tempLong, 0, array, 0, array.length);
	}

	public static long[] asLong(int[] array) {
		long[] result = new long[array.length];
		for (int i = 0; i < array.length; i++)
			result[i] = array[i];
		return result;
	}

	public static int count(int[] array, int value) {
		int result = 0;
		for (int i : array) {
			if (i == value)
				result++;
		}
		return result;
	}

	public static int count(char[] array, char value) {
		int result = 0;
		for (char i : array) {
			if (i == value)
				result++;
		}
		return result;
	}

	public static int count(boolean[] array, boolean value) {
		int result = 0;
		for (boolean i : array) {
			if (i == value)
				result++;
		}
		return result;
	}

	public static int[] merge(int[] first, int[] second) {
		int[] result = new int[first.length + second.length];
		int firstIndex = 0;
		int secondIndex = 0;
		int index = 0;
		while (firstIndex < first.length && secondIndex < second.length) {
			if (first[firstIndex] < second[secondIndex])
				result[index++] = first[firstIndex++];
			else
				result[index++] = second[secondIndex++];
		}
		System.arraycopy(first, firstIndex, result, index, first.length
				- firstIndex);
		System.arraycopy(second, secondIndex, result, index, second.length
				- secondIndex);
		return result;
	}

	public static boolean nextPermutation(int[] array) {
		return nextPermutation(array, IntComparator.DEFAULT);
	}

	private static boolean nextPermutation(int[] array, IntComparator comparator) {
		int size = array.length;
		int last = array[size - 1];
		for (int i = size - 2; i >= 0; i--) {
			int current = array[i];
			if (comparator.compare(last, current) > 0) {
				for (int j = size - 1; j > i; j--) {
					if (comparator.compare(array[j], current) > 0) {
						swap(array, i, j);
						inPlaceReverse(array, i + 1, size);
						return true;
					}
				}
			}
			last = current;
		}
		return false;
	}

	private static void inPlaceReverse(int[] array, int first, int second) {
		for (int i = first, j = second - 1; i < j; i++, j--)
			swap(array, i, j);
	}

	private static void swap(int[] array, int first, int second) {
		if (first == second)
			return;
		int temp = array[first];
		array[first] = array[second];
		array[second] = temp;
	}

	public static <V> void reverse(V[] array) {
		for (int i = 0, j = array.length - 1; i < j; i++, j--) {
			V temp = array[i];
			array[i] = array[j];
			array[j] = temp;
		}
	}

	public static IntComparator compareBy(final int[]... arrays) {
		return new IntComparator() {
			public int compare(Integer first, Integer second) {
				for (int[] array : arrays) {
					if (array[first] != array[second])
						return Integer.compare(array[first], array[second]);
				}
				return 0;
			}
		};
	}

	public static long minElement(long[] array) {
		return array[minPosition(array)];
	}

	public static long maxElement(long[] array) {
		return array[maxPosition(array)];
	}

	public static int minPosition(long[] array) {
		return minPosition(array, 0, array.length);
	}

	public static int maxPosition(long[] array) {
		return maxPosition(array, 0, array.length);
	}

	public static int minPosition(long[] array, int from, int to) {
		if (from >= to)
			return -1;
		long min = array[from];
		int result = from;
		for (int i = from + 1; i < to; i++) {
			if (array[i] < min) {
				min = array[i];
				result = i;
			}
		}
		return result;
	}

	public static int maxPosition(long[] array, int from, int to) {
		if (from >= to)
			return -1;
		long max = array[from];
		int result = from;
		for (int i = from + 1; i < to; i++) {
			if (array[i] > max) {
				max = array[i];
				result = i;
			}
		}
		return result;
	}

	public static int[] createArray(int count, int value) {
		int[] array = new int[count];
		Arrays.fill(array, value);
		return array;
	}

	public static long[] createArray(int count, long value) {
		long[] array = new long[count];
		Arrays.fill(array, value);
		return array;
	}

	public static double[] createArray(int count, double value) {
		double[] array = new double[count];
		Arrays.fill(array, value);
		return array;
	}

	public static boolean[] createArray(int count, boolean value) {
		boolean[] array = new boolean[count];
		Arrays.fill(array, value);
		return array;
	}

	public static char[] createArray(int count, char value) {
		char[] array = new char[count];
		Arrays.fill(array, value);
		return array;
	}

	public static <T> T[] createArray(int count, T value) {
		@SuppressWarnings("unchecked")
		T[] array = (T[]) Array.newInstance(value.getClass(), count);
		Arrays.fill(array, value);
		return array;
	}
}

class Graph {
	public static final int REMOVED_BIT = 0;

	protected int vertexCount;
	protected int edgeCount;

	private int[] firstOutbound;
	private int[] firstInbound;

	private Edge[] edges;
	private int[] nextInbound;
	private int[] nextOutbound;
	private int[] from;
	private int[] to;
	private long[] weight;
	private long[] capacity;
	private int[] reverseEdge;
	private int[] flags;

	public Graph(int vertexCount) {
		this(vertexCount, vertexCount);
	}

	public Graph(int vertexCount, int edgeCapacity) {
		this.vertexCount = vertexCount;
		firstOutbound = new int[vertexCount];
		Arrays.fill(firstOutbound, -1);

		from = new int[edgeCapacity];
		to = new int[edgeCapacity];
		nextOutbound = new int[edgeCapacity];
		flags = new int[edgeCapacity];
	}

	public static Graph createGraph(int vertexCount, int[] from, int[] to) {
		Graph graph = new Graph(vertexCount, from.length);
		for (int i = 0; i < from.length; i++)
			graph.addSimpleEdge(from[i], to[i]);
		return graph;
	}

	public static Graph createWeightedGraph(int vertexCount, int[] from,
			int[] to, long[] weight) {
		Graph graph = new Graph(vertexCount, from.length);
		for (int i = 0; i < from.length; i++)
			graph.addWeightedEdge(from[i], to[i], weight[i]);
		return graph;
	}

	public static Graph createFlowGraph(int vertexCount, int[] from, int[] to,
			long[] capacity) {
		Graph graph = new Graph(vertexCount, from.length * 2);
		for (int i = 0; i < from.length; i++)
			graph.addFlowEdge(from[i], to[i], capacity[i]);
		return graph;
	}

	public static Graph createFlowWeightedGraph(int vertexCount, int[] from,
			int[] to, long[] weight, long[] capacity) {
		Graph graph = new Graph(vertexCount, from.length * 2);
		for (int i = 0; i < from.length; i++)
			graph.addFlowWeightedEdge(from[i], to[i], weight[i], capacity[i]);
		return graph;
	}

	public static Graph createTree(int[] parent) {
		Graph graph = new Graph(parent.length + 1, parent.length);
		for (int i = 0; i < parent.length; i++)
			graph.addSimpleEdge(parent[i], i + 1);
		return graph;
	}

	public int addEdge(int fromID, int toID, long weight, long capacity,
			int reverseEdge) {
		ensureEdgeCapacity(edgeCount + 1);
		if (firstOutbound[fromID] != -1)
			nextOutbound[edgeCount] = firstOutbound[fromID];
		else
			nextOutbound[edgeCount] = -1;
		firstOutbound[fromID] = edgeCount;
		if (firstInbound != null) {
			if (firstInbound[toID] != -1)
				nextInbound[edgeCount] = firstInbound[toID];
			else
				nextInbound[edgeCount] = -1;
			firstInbound[toID] = edgeCount;
		}
		this.from[edgeCount] = fromID;
		this.to[edgeCount] = toID;
		if (capacity != 0) {
			if (this.capacity == null)
				this.capacity = new long[from.length];
			this.capacity[edgeCount] = capacity;
		}
		if (weight != 0) {
			if (this.weight == null)
				this.weight = new long[from.length];
			this.weight[edgeCount] = weight;
		}
		if (reverseEdge != -1) {
			if (this.reverseEdge == null) {
				this.reverseEdge = new int[from.length];
				Arrays.fill(this.reverseEdge, 0, edgeCount, -1);
			}
			this.reverseEdge[edgeCount] = reverseEdge;
		}
		if (edges != null)
			edges[edgeCount] = createEdge(edgeCount);
		return edgeCount++;
	}

	protected final GraphEdge createEdge(int id) {
		return new GraphEdge(id);
	}

	public final int addFlowWeightedEdge(int from, int to, long weight,
			long capacity) {
		if (capacity == 0) {
			return addEdge(from, to, weight, 0, -1);
		} else {
			int lastEdgeCount = edgeCount;
			addEdge(to, from, -weight, 0, lastEdgeCount + entriesPerEdge());
			return addEdge(from, to, weight, capacity, lastEdgeCount);
		}
	}

	protected int entriesPerEdge() {
		return 1;
	}

	public final int addFlowEdge(int from, int to, long capacity) {
		return addFlowWeightedEdge(from, to, 0, capacity);
	}

	public final int addWeightedEdge(int from, int to, long weight) {
		return addFlowWeightedEdge(from, to, weight, 0);
	}

	public final int addSimpleEdge(int from, int to) {
		return addWeightedEdge(from, to, 0);
	}

	public final int vertexCount() {
		return vertexCount;
	}

	public final int edgeCount() {
		return edgeCount;
	}

	protected final int edgeCapacity() {
		return from.length;
	}

	public final Edge edge(int id) {
		initEdges();
		return edges[id];
	}

	public final int firstOutbound(int vertex) {
		int id = firstOutbound[vertex];
		while (id != -1 && isRemoved(id))
			id = nextOutbound[id];
		return id;
	}

	public final int nextOutbound(int id) {
		id = nextOutbound[id];
		while (id != -1 && isRemoved(id))
			id = nextOutbound[id];
		return id;
	}

	public final int firstInbound(int vertex) {
		initInbound();
		int id = firstInbound[vertex];
		while (id != -1 && isRemoved(id))
			id = nextInbound[id];
		return id;
	}

	public final int nextInbound(int id) {
		initInbound();
		id = nextInbound[id];
		while (id != -1 && isRemoved(id))
			id = nextInbound[id];
		return id;
	}

	public final int source(int id) {
		return from[id];
	}

	public final int destination(int id) {
		return to[id];
	}

	public final long weight(int id) {
		if (weight == null)
			return 0;
		return weight[id];
	}

	public final long capacity(int id) {
		if (capacity == null)
			return 0;
		return capacity[id];
	}

	public final long flow(int id) {
		if (reverseEdge == null)
			return 0;
		return capacity[reverseEdge[id]];
	}

	public final void pushFlow(int id, long flow) {
		if (flow == 0)
			return;
		if (flow > 0) {
			if (capacity(id) < flow)
				throw new IllegalArgumentException("Not enough capacity");
		} else {
			if (flow(id) < -flow)
				throw new IllegalArgumentException("Not enough capacity");
		}
		capacity[id] -= flow;
		capacity[reverseEdge[id]] += flow;
	}

	public int transposed(int id) {
		return -1;
	}

	public final int reverse(int id) {
		if (reverseEdge == null)
			return -1;
		return reverseEdge[id];
	}

	public final void addVertices(int count) {
		ensureVertexCapacity(vertexCount + count);
		Arrays.fill(firstOutbound, vertexCount, vertexCount + count, -1);
		if (firstInbound != null)
			Arrays.fill(firstInbound, vertexCount, vertexCount + count, -1);
		vertexCount += count;
	}

	protected final void initEdges() {
		if (edges == null) {
			edges = new Edge[from.length];
			for (int i = 0; i < edgeCount; i++)
				edges[i] = createEdge(i);
		}
	}

	public final void removeVertex(int vertex) {
		int id = firstOutbound[vertex];
		while (id != -1) {
			removeEdge(id);
			id = nextOutbound[id];
		}
		initInbound();
		id = firstInbound[vertex];
		while (id != -1) {
			removeEdge(id);
			id = nextInbound[id];
		}
	}

	private void initInbound() {
		if (firstInbound == null) {
			firstInbound = new int[firstOutbound.length];
			Arrays.fill(firstInbound, 0, vertexCount, -1);
			nextInbound = new int[from.length];
			for (int i = 0; i < edgeCount; i++) {
				nextInbound[i] = firstInbound[to[i]];
				firstInbound[to[i]] = i;
			}
		}
	}

	public final boolean flag(int id, int bit) {
		return (flags[id] >> bit & 1) != 0;
	}

	public final void setFlag(int id, int bit) {
		flags[id] |= 1 << bit;
	}

	public final void removeFlag(int id, int bit) {
		flags[id] &= -1 - (1 << bit);
	}

	public final void removeEdge(int id) {
		setFlag(id, REMOVED_BIT);
	}

	public final void restoreEdge(int id) {
		removeFlag(id, REMOVED_BIT);
	}

	public final boolean isRemoved(int id) {
		return flag(id, REMOVED_BIT);
	}

	public final Iterable<Edge> outbound(final int id) {
		initEdges();
		return new Iterable<Edge>() {
			public Iterator<Edge> iterator() {
				return new EdgeIterator(id, firstOutbound, nextOutbound);
			}
		};
	}

	public final Iterable<Edge> inbound(final int id) {
		initEdges();
		initInbound();
		return new Iterable<Edge>() {
			public Iterator<Edge> iterator() {
				return new EdgeIterator(id, firstInbound, nextInbound);
			}
		};
	}

	protected void ensureEdgeCapacity(int size) {
		if (from.length < size) {
			int newSize = Math.max(size, 2 * from.length);
			if (edges != null)
				edges = resize(edges, newSize);
			from = resize(from, newSize);
			to = resize(to, newSize);
			nextOutbound = resize(nextOutbound, newSize);
			if (nextInbound != null)
				nextInbound = resize(nextInbound, newSize);
			if (weight != null)
				weight = resize(weight, newSize);
			if (capacity != null)
				capacity = resize(capacity, newSize);
			if (reverseEdge != null)
				reverseEdge = resize(reverseEdge, newSize);
			flags = resize(flags, newSize);
		}
	}

	private void ensureVertexCapacity(int size) {
		if (firstOutbound.length < size) {
			int newSize = Math.max(size, 2 * from.length);
			firstOutbound = resize(firstOutbound, newSize);
			if (firstInbound != null)
				firstInbound = resize(firstInbound, newSize);
		}
	}

	protected final int[] resize(int[] array, int size) {
		int[] newArray = new int[size];
		System.arraycopy(array, 0, newArray, 0, array.length);
		return newArray;
	}

	private long[] resize(long[] array, int size) {
		long[] newArray = new long[size];
		System.arraycopy(array, 0, newArray, 0, array.length);
		return newArray;
	}

	private Edge[] resize(Edge[] array, int size) {
		Edge[] newArray = new Edge[size];
		System.arraycopy(array, 0, newArray, 0, array.length);
		return newArray;
	}

	public final boolean isSparse() {
		return vertexCount == 0 || edgeCount * 20 / vertexCount <= vertexCount;
	}

	protected class GraphEdge implements Edge {
		protected int id;

		protected GraphEdge(int id) {
			this.id = id;
		}

		public int getSource() {
			return source(id);
		}

		public int getDestination() {
			return destination(id);
		}

		public long getWeight() {
			return weight(id);
		}

		public long getCapacity() {
			return capacity(id);
		}

		public long getFlow() {
			return flow(id);
		}

		public void pushFlow(long flow) {
			Graph.this.pushFlow(id, flow);
		}

		public boolean getFlag(int bit) {
			return flag(id, bit);
		}

		public void setFlag(int bit) {
			Graph.this.setFlag(id, bit);
		}

		public void removeFlag(int bit) {
			Graph.this.removeFlag(id, bit);
		}

		public int getTransposedID() {
			return transposed(id);
		}

		public Edge getTransposedEdge() {
			int reverseID = getTransposedID();
			if (reverseID == -1)
				return null;
			initEdges();
			return edge(reverseID);
		}

		public int getReverseID() {
			return reverse(id);
		}

		public Edge getReverseEdge() {
			int reverseID = getReverseID();
			if (reverseID == -1)
				return null;
			initEdges();
			return edge(reverseID);
		}

		public int getID() {
			return id;
		}

		public void remove() {
			removeEdge(id);
		}

		public void restore() {
			restoreEdge(id);
		}
	}

	public class EdgeIterator implements Iterator<Edge> {
		private int edgeID;
		private final int[] next;
		private int lastID = -1;

		public EdgeIterator(int id, int[] first, int[] next) {
			this.next = next;
			edgeID = nextEdge(first[id]);
		}

		private int nextEdge(int id) {
			while (id != -1 && isRemoved(id))
				id = next[id];
			return id;
		}

		public boolean hasNext() {
			return edgeID != -1;
		}

		public Edge next() {
			if (edgeID == -1)
				throw new NoSuchElementException();
			lastID = edgeID;
			edgeID = nextEdge(next[lastID]);
			return edges[lastID];
		}

		public void remove() {
			if (lastID == -1)
				throw new IllegalStateException();
			removeEdge(lastID);
			lastID = -1;
		}
	}

}

class MiscUtils {
	public static final int[] DX4 = { 1, 0, -1, 0 };
	public static final int[] DY4 = { 0, -1, 0, 1 };
	public static final int[] DX8 = { 1, 1, 1, 0, -1, -1, -1, 0 };
	public static final int[] DY8 = { -1, 0, 1, 1, 1, 0, -1, -1 };
	public static final int[] DX_KNIGHT = { 2, 1, -1, -2, -2, -1, 1, 2 };
	public static final int[] DY_KNIGHT = { 1, 2, 2, 1, -1, -2, -2, -1 };

	private static final String[] ROMAN_TOKENS = { "M", "CM", "D", "CD", "C",
			"XC", "L", "XL", "X", "IX", "V", "IV", "I" };
	private static final int[] ROMAN_VALUES = { 1000, 900, 500, 400, 100, 90,
			50, 40, 10, 9, 5, 4, 1 };

	public static long josephProblem(long n, int k) {
		if (n == 1)
			return 0;
		if (k == 1)
			return n - 1;
		if (k > n)
			return (josephProblem(n - 1, k) + k) % n;
		long count = n / k;
		long result = josephProblem(n - count, k);
		result -= n % k;
		if (result < 0)
			result += n;
		else
			result += result / (k - 1);
		return result;
	}

	public static boolean isValidCell(int row, int column, int rowCount,
			int columnCount) {
		return row >= 0 && row < rowCount && column >= 0
				&& column < columnCount;
	}

	public static List<Integer> getPath(int[] last, int destination) {
		List<Integer> path = new ArrayList<Integer>();
		while (destination != -1) {
			path.add(destination);
			destination = last[destination];
		}
		inPlaceReverse(path);
		return path;
	}

	private static void inPlaceReverse(List<Integer> list) {
		for (int i = 0, j = list.size() - 1; i < j; i++, j--)
			swap(list, i, j);
	}

	private static void swap(List<Integer> list, int first, int second) {
		if (first == second)
			return;
		int temp = list.get(first);
		list.set(first, list.get(second));
		list.set(second, temp);
	}

	public static List<Integer> getPath(int[][] lastIndex,
			int[][] lastPathNumber, int destination, int pathNumber) {
		List<Integer> path = new ArrayList<Integer>();
		while (destination != -1 || pathNumber != 0) {
			path.add(destination);
			int nextDestination = lastIndex[destination][pathNumber];
			pathNumber = lastPathNumber[destination][pathNumber];
			destination = nextDestination;
		}
		inPlaceReverse(path);
		return path;
	}

	public static long maximalRectangleSum(long[][] array) {
		int n = array.length;
		int m = array[0].length;
		long[][] partialSums = new long[n + 1][m + 1];
		for (int i = 0; i < n; i++) {
			long rowSum = 0;
			for (int j = 0; j < m; j++) {
				rowSum += array[i][j];
				partialSums[i + 1][j + 1] = partialSums[i][j + 1] + rowSum;
			}
		}
		long result = Long.MIN_VALUE;
		for (int i = 0; i < m; i++) {
			for (int j = i; j < m; j++) {
				long minPartialSum = 0;
				for (int k = 1; k <= n; k++) {
					long current = partialSums[k][j + 1] - partialSums[k][i];
					result = Math.max(result, current - minPartialSum);
					minPartialSum = Math.min(minPartialSum, current);
				}
			}
		}
		return result;
	}

	public static int parseIP(String ip) {
		String[] components = ip.split("[.]");
		int result = 0;
		for (int i = 0; i < 4; i++)
			result += (1 << (24 - 8 * i)) * Integer.parseInt(components[i]);
		return result;
	}

	public static String buildIP(int mask) {
		StringBuilder result = new StringBuilder();
		for (int i = 0; i < 4; i++) {
			if (i != 0)
				result.append('.');
			result.append(mask >> (24 - 8 * i) & 255);
		}
		return result.toString();
	}

	public static long binarySearch(long from, long to,
			Function<Long, Boolean> function) {
		while (from < to) {
			long argument = from + (to - from) / 2;
			if (function.value(argument))
				to = argument;
			else
				from = argument + 1;
		}
		return from;
	}

	public static <T> boolean equals(T first, T second) {
		return first == null && second == null || first != null
				&& first.equals(second);
	}

	public static boolean isVowel(char ch) {
		ch = Character.toUpperCase(ch);
		return ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U'
				|| ch == 'Y';
	}

	public static boolean isStrictVowel(char ch) {
		ch = Character.toUpperCase(ch);
		return ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U';
	}

	public static String convertToRoman(int number) {
		StringBuilder result = new StringBuilder();
		for (int i = 0; i < ROMAN_TOKENS.length; i++) {
			while (number >= ROMAN_VALUES[i]) {
				number -= ROMAN_VALUES[i];
				result.append(ROMAN_TOKENS[i]);
			}
		}
		return result.toString();
	}

	public static int convertFromRoman(String number) {
		int result = 0;
		for (int i = 0; i < ROMAN_TOKENS.length; i++) {
			while (number.startsWith(ROMAN_TOKENS[i])) {
				number = number.substring(ROMAN_TOKENS[i].length());
				result += ROMAN_VALUES[i];
			}
		}
		return result;
	}

	public static int distance(int x1, int y1, int x2, int y2) {
		int dx = x1 - x2;
		int dy = y1 - y2;
		return dx * dx + dy * dy;
	}

	public static <T extends Comparable<T>> T min(T first, T second) {
		if (first.compareTo(second) <= 0)
			return first;
		return second;
	}

	public static <T extends Comparable<T>> T max(T first, T second) {
		if (first.compareTo(second) <= 0)
			return second;
		return first;
	}

	public static void decreaseByOne(int[]... arrays) {
		for (int[] array : arrays) {
			for (int i = 0; i < array.length; i++)
				array[i]--;
		}
	}

	public static int[] getIntArray(String s) {
		String[] tokens = s.split(" ");
		int[] result = new int[tokens.length];
		for (int i = 0; i < result.length; i++)
			result[i] = Integer.parseInt(tokens[i]);
		return result;
	}
}

class IntegerUtils {
	public static long gcd(long a, long b) {
		a = Math.abs(a);
		b = Math.abs(b);
		while (b != 0) {
			long temp = a % b;
			a = b;
			b = temp;
		}
		return a;
	}

	public static int gcd(int a, int b) {
		a = Math.abs(a);
		b = Math.abs(b);
		while (b != 0) {
			int temp = a % b;
			a = b;
			b = temp;
		}
		return a;
	}

	public static int[] generatePrimes(int upTo) {
		int[] isPrime = generateBitPrimalityTable(upTo);
		List<Integer> primes = new ArrayList<Integer>();
		for (int i = 0; i < upTo; i++) {
			if ((isPrime[i >> 5] >>> (i & 31) & 1) == 1)
				primes.add(i);
		}
		int[] array = new int[primes.size()];
		for (int i = 0; i < array.length; i++)
			array[i] = primes.get(i);
		return array;
	}

	public static boolean[] generatePrimalityTable(int upTo) {
		boolean[] isPrime = new boolean[upTo];
		if (upTo < 2)
			return isPrime;
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i * i < upTo; i++) {
			if (isPrime[i]) {
				for (int j = i * i; j < upTo; j += i)
					isPrime[j] = false;
			}
		}
		return isPrime;
	}

	public static int[] generateBitPrimalityTable(int upTo) {
		int[] isPrime = new int[(upTo + 31) >> 5];
		if (upTo < 2)
			return isPrime;
		Arrays.fill(isPrime, -1);
		isPrime[0] &= -4;
		for (int i = 2; i * i < upTo; i++) {
			if ((isPrime[i >> 5] >>> (i & 31) & 1) == 1) {
				for (int j = i * i; j < upTo; j += i)
					isPrime[j >> 5] &= -1 - (1 << (j & 31));
			}
		}
		return isPrime;
	}

	public static int[] generateDivisorTable(int upTo) {
		int[] divisor = new int[upTo];
		for (int i = 1; i < upTo; i++)
			divisor[i] = i;
		for (int i = 2; i * i < upTo; i++) {
			if (divisor[i] == i) {
				for (int j = i * i; j < upTo; j += i)
					divisor[j] = i;
			}
		}
		return divisor;
	}

	public static long powerInFactorial(long n, long p) {
		long result = 0;
		while (n != 0) {
			result += n /= p;
		}
		return result;
	}

	public static int sumDigits(CharSequence number) {
		int result = 0;
		for (int i = number.length() - 1; i >= 0; i--)
			result += digitValue(number.charAt(i));
		return result;
	}

	public static int digitValue(char digit) {
		if (Character.isDigit(digit))
			return digit - '0';
		if (Character.isUpperCase(digit))
			return digit + 10 - 'A';
		return digit + 10 - 'a';
	}

	public static int longCompare(long a, long b) {
		if (a < b)
			return -1;
		if (a > b)
			return 1;
		return 0;
	}

	public static long[][] generateBinomialCoefficients(int n) {
		long[][] result = new long[n + 1][n + 1];
		for (int i = 0; i <= n; i++) {
			result[i][0] = 1;
			for (int j = 1; j <= i; j++)
				result[i][j] = result[i - 1][j - 1] + result[i - 1][j];
		}
		return result;
	}

	public static long[][] generateBinomialCoefficients(int n, long module) {
		long[][] result = new long[n + 1][n + 1];
		if (module == 1)
			return result;
		for (int i = 0; i <= n; i++) {
			result[i][0] = 1;
			for (int j = 1; j <= i; j++) {
				result[i][j] = result[i - 1][j - 1] + result[i - 1][j];
				if (result[i][j] >= module)
					result[i][j] -= module;
			}
		}
		return result;
	}

	public static long[] generateBinomialRow(int n, long module) {
		long[] result = generateReverse(n + 1, module);
		result[0] = 1;
		for (int i = 1; i <= n; i++)
			result[i] = result[i - 1] * (n - i + 1) % module * result[i]
					% module;
		return result;
	}

	public static int[] representationInBase(long number, int base) {
		long basePower = base;
		int exponent = 1;
		while (number >= basePower) {
			basePower *= base;
			exponent++;
		}
		int[] representation = new int[exponent];
		for (int i = 0; i < exponent; i++) {
			basePower /= base;
			representation[i] = (int) (number / basePower);
			number %= basePower;
		}
		return representation;
	}

	public static int trueDivide(int a, int b) {
		return (a - trueMod(a, b)) / b;
	}

	public static long trueDivide(long a, long b) {
		return (a - trueMod(a, b)) / b;
	}

	public static int trueMod(int a, int b) {
		a %= b;
		a += b;
		a %= b;
		return a;
	}

	public static long trueMod(long a, long b) {
		a %= b;
		a += b;
		a %= b;
		return a;
	}

	public static long factorial(int n) {
		long result = 1;
		for (int i = 2; i <= n; i++)
			result *= i;
		return result;
	}

	public static long factorial(int n, long mod) {
		long result = 1;
		for (int i = 2; i <= n; i++)
			result = result * i % mod;
		return result % mod;
	}

	public static List<Pair<Long, Integer>> factorize(long number) {
		List<Pair<Long, Integer>> result = new ArrayList<Pair<Long, Integer>>();
		for (long i = 2; i * i <= number; i++) {
			if (number % i == 0) {
				int power = 0;
				do {
					power++;
					number /= i;
				} while (number % i == 0);
				result.add(Pair.makePair(i, power));
			}
		}
		if (number != 1)
			result.add(Pair.makePair(number, 1));
		return result;
	}

	public static List<Long> getDivisors(long number) {
		List<Pair<Long, Integer>> primeDivisors = factorize(number);
		return getDivisorsImpl(primeDivisors, 0, 1, new ArrayList<Long>());
	}

	private static List<Long> getDivisorsImpl(
			List<Pair<Long, Integer>> primeDivisors, int index, long current,
			List<Long> result) {
		if (index == primeDivisors.size()) {
			result.add(current);
			return result;
		}
		long p = primeDivisors.get(index).first;
		int power = primeDivisors.get(index).second;
		for (int i = 0; i <= power; i++) {
			getDivisorsImpl(primeDivisors, index + 1, current, result);
			current *= p;
		}
		return result;
	}

	public static long power(long base, long exponent) {
		if (exponent == 0)
			return 1;
		long result = power(base, exponent >> 1);
		result = result * result;
		if ((exponent & 1) != 0)
			result = result * base;
		return result;
	}

	public static long power(long base, long exponent, long mod) {
		if (base >= mod)
			base %= mod;
		if (exponent == 0)
			return 1 % mod;
		long result = power(base, exponent >> 1, mod);
		result = result * result % mod;
		if ((exponent & 1) != 0)
			result = result * base % mod;
		return result;
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long[] generateFibonacci(long upTo) {
		int count = 0;
		long last = 0;
		long current = 1;
		while (current <= upTo) {
			long next = last + current;
			last = current;
			current = next;
			count++;
		}
		return generateFibonacci(count, -1);
	}

	public static long[] generateFibonacci(int count, long module) {
		long[] result = new long[count];
		if (module == -1) {
			if (count != 0)
				result[0] = 1;
			if (count > 1)
				result[1] = 1;
			for (int i = 2; i < count; i++)
				result[i] = result[i - 1] + result[i - 2];
		} else {
			if (count != 0)
				result[0] = 1 % module;
			if (count > 1)
				result[1] = 1 % module;
			for (int i = 2; i < count; i++)
				result[i] = (result[i - 1] + result[i - 2]) % module;
		}
		return result;
	}

	public static long[] generateHappy(int digits) {
		long[] happy = new long[(1 << (digits + 1)) - 2];
		happy[0] = 4;
		happy[1] = 7;
		int first = 0;
		int last = 2;
		for (int i = 2; i <= digits; i++) {
			for (int j = 0; j < last - first; j++) {
				happy[last + 2 * j] = 10 * happy[first + j] + 4;
				happy[last + 2 * j + 1] = 10 * happy[first + j] + 7;
			}
			int next = last + 2 * (last - first);
			first = last;
			last = next;
		}
		return happy;
	}

	public static long[] generateFactorial(int count, long module) {
		long[] result = new long[count];
		if (module == -1) {
			if (count != 0)
				result[0] = 1;
			for (int i = 1; i < count; i++)
				result[i] = result[i - 1] * i;
		} else {
			if (count != 0)
				result[0] = 1 % module;
			for (int i = 1; i < count; i++)
				result[i] = (result[i - 1] * i) % module;
		}
		return result;
	}

	public static long reverse(long number, long module) {
		return power(number, module - 2, module);
	}

	public static boolean isPrime(long number) {
		if (number < 2)
			return false;
		for (long i = 2; i * i <= number; i++) {
			if (number % i == 0)
				return false;
		}
		return true;
	}

	public static long[] generateReverse(int upTo, long module) {
		long[] result = new long[upTo];
		if (upTo > 1)
			result[1] = 1;
		for (int i = 2; i < upTo; i++)
			result[i] = (module - module / i * result[((int) (module % i))]
					% module)
					% module;
		return result;
	}

	public static long[] generateReverseFactorials(int upTo, long module) {
		long[] result = generateReverse(upTo, module);
		if (upTo > 0)
			result[0] = 1;
		for (int i = 1; i < upTo; i++)
			result[i] = result[i] * result[i - 1] % module;
		return result;
	}

	public static long[] generatePowers(long base, int count, long mod) {
		long[] result = new long[count];
		if (count != 0)
			result[0] = 1 % mod;
		for (int i = 1; i < count; i++)
			result[i] = result[i - 1] * base % mod;
		return result;
	}

	public static long nextPrime(long from) {
		if (from <= 2)
			return 2;
		from += 1 - (from & 1);
		while (!isPrime(from))
			from += 2;
		return from;
	}

	public static long binomialCoefficient(int n, int m, long mod) {
		if (m < 0 || m > n)
			return 0;
		if (2 * m > n)
			m = n - m;
		long result = 1;
		for (int i = n - m + 1; i <= n; i++)
			result = result * i % mod;
		return result
				* BigInteger.valueOf(factorial(m, mod))
						.modInverse(BigInteger.valueOf(mod)).longValue() % mod;
	}

	public static boolean isSquare(long number) {
		long sqrt = Math.round(Math.sqrt(number));
		return sqrt * sqrt == number;
	}

	public static long findCommon(long aRemainder, long aMod, long bRemainder,
			long bMod) {
		long modGCD = gcd(aMod, bMod);
		long gcdRemainder = aRemainder % modGCD;
		if (gcdRemainder != bRemainder % modGCD)
			return -1;
		aMod /= modGCD;
		aRemainder /= modGCD;
		bMod /= modGCD;
		bRemainder /= modGCD;
		long aReverse = BigInteger.valueOf(aMod)
				.modInverse(BigInteger.valueOf(bMod)).longValue();
		long bReverse = BigInteger.valueOf(bMod)
				.modInverse(BigInteger.valueOf(aMod)).longValue();
		long mod = aMod * bMod;
		return (bReverse * aRemainder % mod * bMod + aReverse * bRemainder
				% mod * aMod)
				% mod * modGCD + gcdRemainder;
	}

	public static long[] generatePowers(long base, long maxValue) {
		if (maxValue <= 0)
			return new long[0];
		int size = 1;
		long current = 1;
		while (maxValue / base >= current) {
			current *= base;
			size++;
		}
		return generatePowers(base, size, Long.MAX_VALUE);
	}
}

interface IntComparator extends Comparator<Integer> {
	public static final IntComparator DEFAULT = new IntComparator() {
		public int compare(Integer first, Integer second) {
			if (first < second)
				return -1;
			if (first > second)
				return 1;
			return 0;
		}
	};

	public static final IntComparator REVERSE = new IntComparator() {
		public int compare(Integer first, Integer second) {
			if (first < second)
				return 1;
			if (first > second)
				return -1;
			return 0;
		}
	};

	public int compare(Integer first, Integer second);
}

class BidirectionalGraph extends Graph {
	public int[] transposedEdge;

	public BidirectionalGraph(int vertexCount) {
		this(vertexCount, vertexCount);
	}

	public BidirectionalGraph(int vertexCount, int edgeCapacity) {
		super(vertexCount, 2 * edgeCapacity);
		transposedEdge = new int[2 * edgeCapacity];
	}

	public static BidirectionalGraph createGraph(int vertexCount, int[] from,
			int[] to) {
		BidirectionalGraph graph = new BidirectionalGraph(vertexCount,
				from.length);
		for (int i = 0; i < from.length; i++)
			graph.addSimpleEdge(from[i], to[i]);
		return graph;
	}

	public static BidirectionalGraph createWeightedGraph(int vertexCount,
			int[] from, int[] to, long[] weight) {
		BidirectionalGraph graph = new BidirectionalGraph(vertexCount,
				from.length);
		for (int i = 0; i < from.length; i++)
			graph.addWeightedEdge(from[i], to[i], weight[i]);
		return graph;
	}

	public static BidirectionalGraph createFlowGraph(int vertexCount,
			int[] from, int[] to, long[] capacity) {
		BidirectionalGraph graph = new BidirectionalGraph(vertexCount,
				from.length * 2);
		for (int i = 0; i < from.length; i++)
			graph.addFlowEdge(from[i], to[i], capacity[i]);
		return graph;
	}

	public static BidirectionalGraph createFlowWeightedGraph(int vertexCount,
			int[] from, int[] to, long[] weight, long[] capacity) {
		BidirectionalGraph graph = new BidirectionalGraph(vertexCount,
				from.length * 2);
		for (int i = 0; i < from.length; i++)
			graph.addFlowWeightedEdge(from[i], to[i], weight[i], capacity[i]);
		return graph;
	}

	@Override
	public int addEdge(int fromID, int toID, long weight, long capacity,
			int reverseEdge) {
		int lastEdgeCount = edgeCount;
		super.addEdge(fromID, toID, weight, capacity, reverseEdge);
		super.addEdge(toID, fromID, weight, capacity, reverseEdge == -1 ? -1
				: reverseEdge + 1);
		this.transposedEdge[lastEdgeCount] = lastEdgeCount + 1;
		this.transposedEdge[lastEdgeCount + 1] = lastEdgeCount;
		return lastEdgeCount;
	}

	@Override
	protected int entriesPerEdge() {
		return 2;
	}

	@Override
	public final int transposed(int id) {
		return transposedEdge[id];
	}

	@Override
	protected void ensureEdgeCapacity(int size) {
		if (size > edgeCapacity()) {
			super.ensureEdgeCapacity(size);
			transposedEdge = resize(transposedEdge, edgeCapacity());
		}
	}
}

class Pair<U, V> implements Comparable<Pair<U, V>> {
	public final U first;
	public final V second;

	public static <U, V> Pair<U, V> makePair(U first, V second) {
		return new Pair<U, V>(first, second);
	}

	private Pair(U first, V second) {
		this.first = first;
		this.second = second;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		Pair pair = (Pair) o;

		return !(first != null ? !first.equals(pair.first) : pair.first != null)
				&& !(second != null ? !second.equals(pair.second)
						: pair.second != null);

	}

	@Override
	public int hashCode() {
		int result = first != null ? first.hashCode() : 0;
		result = 31 * result + (second != null ? second.hashCode() : 0);
		return result;
	}

	public Pair<V, U> swap() {
		return makePair(second, first);
	}

	@Override
	public String toString() {
		return "(" + first + "," + second + ")";
	}

	@SuppressWarnings({ "unchecked" })
	public int compareTo(Pair<U, V> o) {
		int value = ((Comparable<U>) first).compareTo(o.first);
		if (value != 0)
			return value;
		return ((Comparable<V>) second).compareTo(o.second);
	}
}

interface Edge {
	public int getSource();

	public int getDestination();

	public long getWeight();

	public long getCapacity();

	public long getFlow();

	public void pushFlow(long flow);

	public boolean getFlag(int bit);

	public void setFlag(int bit);

	public void removeFlag(int bit);

	public int getTransposedID();

	public Edge getTransposedEdge();

	public int getReverseID();

	public Edge getReverseEdge();

	public int getID();

	public void remove();

	public void restore();
}

interface Function<A, V> {
	public abstract V value(A argument);
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		int sum=n;
		while(n!=1){
			int max=1;
			for(int i=2;i<=Math.sqrt(n);i++){
				if(n%i==0)
					max=Math.max(i, n/i);
			}
			if(max==0)
				break;
			sum+=max;
			n=max;
		}
		System.out.println(sum);
		br.close();
	}// end of main(String[])

}// end of class Main

import java.io.PrintWriter;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author admin
 */
public class P177B1 {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int c = n;
        for(int i = 2; i < Math.sqrt(n); ++i)
        {
            while(n % i == 0)
            {
                c = c + n / i;
                n = n / i;
            }
        }
        if(n > 1)
            c++;
        out.print(c);
        out.close();
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Solution {
    //<editor-fold desc="input parse" defaultstate="collapsed">

    private static StringTokenizer st;
    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    private static long nextLong() {
        return Long.parseLong(st.nextToken());
    }

    private static int nextInt() {
        return Integer.parseInt(st.nextToken());
    }

    private static double nextDouble() {
        return Double.parseDouble(st.nextToken());
    }

    private static short nextShort() {
        return Short.parseShort(st.nextToken());
    }

    private static byte nextByte() {
        return Byte.parseByte(st.nextToken());
    }

    private static void initTokenizer() throws Exception {
        st = new StringTokenizer(reader.readLine());
    }

    //</editor-fold>

    private static HashMap<Integer, Long> target;

    private static long bestSum = 0L;

    private static void relax(HashMap<Integer, Long> map, int c, long sum) {
        if (c > 1) {
            if (map.containsKey(c) && map.get(c) < sum) {
                map.put(c, sum);
            }
            else map.put(c, sum);
        }
        else bestSum = Math.max(bestSum, sum);
    }

    private static ArrayList<Integer> getDivs(int a) {
        int lim = (int)Math.sqrt(a);

        ArrayList<Integer> divs = new ArrayList<>(lim);

        for (int i = 2; i <= lim; i++) {
            if (a % i == 0) {
                divs.add(i);
                divs.add(a / i);
            }
        }

        divs.add(1);

        return divs;
    }

    public static void main(String[] args) throws Exception {
        initTokenizer();

        int n = nextInt();

        target = new HashMap<>();

        relax(target, n, n);

        while (!target.isEmpty()) {
            HashMap<Integer, Long> next = new HashMap<>();

            for (Map.Entry<Integer, Long> e : target.entrySet()) {
                ArrayList<Integer> divs = getDivs(e.getKey());
                //System.out.println(e.getKey());
                //System.out.println(divs.toString());

                for (int i = 0; i < divs.size(); i++) {
                    relax(next, divs.get(i), e.getValue() + divs.get(i));
                }
            }

            target = next;
        }

        System.out.println(bestSum);
    }
}

import java.util.Scanner;

public class Prob177B1 {
	public static void main(String[] Args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		long answer = x;
		for (int i = 2; i * i < x; i++) {
			while (x % i == 0) {
				x /= i;
				answer += x;
			}
		}

		if (x > 1)
			answer++;

		System.out.println(answer);
	}
}

import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        int n = new Scanner(System.in).nextInt();
        long ans = n;
        while  (n%2 == 0){
            n /= 2;
            ans += n;
        }
        if (n != 1 ) ans++;
        System.out.println(ans);
    }
}

import java.util.Scanner;

public class Easy {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        if (n % 2 == 0) {
            sum += n;
            while (n != 0) {
                if (n%2 == 1 || n == 2) {
                    sum++;
                    break;
                }
                sum += n / 2;
                n /= 2;
            }
        }
        else {
            sum = sum + n + 1;
        }
        System.out.println(sum);
        sc.close();
    }
}

import java.util.Scanner;

public class Easy {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;

        if (n % 2 == 0) {
            sum += n;
            while (n != 0) {

                if (n%2 == 1) {
                    sum++;
                    break;
                }
                sum += n / 2;
                n /= 2;
            }
        }
        else {
            sum = sum + n + 1;
        }

        System.out.println(sum);
        sc.close();
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class CodeForces {

	public static void main(String[] args) throws IOException,NumberFormatException{
		try {
			FastScanner sc=new FastScanner();
			int n=sc.nextInt();
			if(n%2!=0) {
				if(isPerfectSquare(n)) {
					System.out.println(n+(int)Math.sqrt(n)+1);
				}
				else {
					System.out.println(n+1);
				}

			}
			else {
                int ans=n;
				while(n%2==0) {
					ans+=n/2;
					n/=2;
				}
				if(n==1)
				System.out.println(ans);
				else {
					if(isPerfectSquare(n)) {
						System.out.println(ans+(int)Math.sqrt(n)+1);
					}
					else {
						System.out.println(ans+1);
					}
				}
			}

		}
		catch(Exception e) {
			return ;
		}

	}

	public static boolean isPerfectSquare(int n) {
		int ans=(int)Math.sqrt(n);
		if(ans*ans==n)
			return true;
		else
			return false;
	}
	public static int GCD(int a,int b) {
		if(b==0)
			return a;
		return GCD(b,a%b);
	}
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
                                      st=new StringTokenizer(br.readLine());
                              } catch (IOException e) {}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}

	}
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class CodeForces {

	public static void main(String[] args) throws IOException,NumberFormatException{
		try {
			FastScanner sc=new FastScanner();
			int n=sc.nextInt();
			if(n%2!=0) {
				System.out.println(n+1);
			}
			else {
                int ans=n;
				while(n%2==0) {
					ans+=n/2;
					n/=2;
				}
				if(n!=1)
					ans+=1;
				System.out.println(ans);
			}

		}
		catch(Exception e) {
			return ;
		}

	}

	public static int GCD(int a,int b) {
		if(b==0)
			return a;
		return GCD(b,a%b);
	}
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
                                      st=new StringTokenizer(br.readLine());
                              } catch (IOException e) {}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}

	}
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class CodeForces {

	public static void main(String[] args) throws IOException,NumberFormatException{
		try {
			FastScanner sc=new FastScanner();
			int n=sc.nextInt();
			if(n%2!=0) {
				System.out.println(n+1);
			}
			else {
                int ans=n;
				while(n%2==0) {
					ans+=n/2;
					n/=2;
				}
				if(n==1)
				System.out.println(ans);
				else {
					if(isPerfectSquare(n)) {
						System.out.println(ans+(int)Math.sqrt(n)+1);
					}
					else {
						System.out.println(ans+1);
					}
				}
			}

		}
		catch(Exception e) {
			return ;
		}

	}

	public static boolean isPerfectSquare(int n) {
		int ans=(int)Math.sqrt(n);
		if(ans*ans==n)
			return true;
		else
			return false;
	}
	public static int GCD(int a,int b) {
		if(b==0)
			return a;
		return GCD(b,a%b);
	}
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
                                      st=new StringTokenizer(br.readLine());
                              } catch (IOException e) {}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}

	}
}

import java.util.Scanner;
public class rectangulargame{
	public static void main(String args[]){
		Scanner input= new Scanner(System.in);
		int n=input.nextInt();
		int ans=n;
		while(n>1){
			if(n%2==0){
				ans+=(int)n/2;
				n=n/2;
			}
			else{
				ans+=1;
				break;
			}
		}
		System.out.println(ans);
	}
}

import java.util.Scanner;

public class B177_RectangularGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int cnt = n;
        boolean flag = true;
        boolean exit = true;
        while (n != 1) {
            if (n % 2 == 0) {
                n /= 2;
                cnt += n;
                exit = true;
            } else {
                int i;
                for (i = n / 2 + 1; i >= 2; i--) {
                    if (n % i == 0) {
                        n /= i;
                        cnt += n;
                        flag = false;
                        break;
                    }
                }
                exit = false;
                if (i == 1 || !flag) break;
            }
        }
        System.out.println(exit ? cnt : ++cnt);
    }
}

import java.util.Scanner;

public class B177_RectangularGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int cnt = n;
        boolean flag = true;
        while (n != 1) {
            if (n % 2 == 0) {
                n /= 2;
                cnt += n;
            } else {
                flag = false;
                break;
            }
        }
        System.out.println(flag ? cnt : ++cnt);
    }
}

import java.io.*;
import java.util.*;
public class RectangularGameE
{
    static int factorcount(int n)
    {
        int r=0;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                r++;
            }
        }
        return r;
    }
    static int factor(int n, int pf)
    {
        int r=0;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0 && (n/i)<pf)
            {
                if((n/i)%2==0)
                {
                    r=n/i;
                    break;
                }
                else if((n/i)%2!=0 && factorcount((n/i))==0)
                {
                    r=n/i;
                    break;
                }
            }
        }
        return r;
    }
    static int lasttry(int n, int pf)
    {
        int r=0;
        for(int i=2;i*i<=n;i++)
        {
            if(n%(n/i)==0 && i<pf)
            {
                if(i%2==0)
                {
                    r=i;
                    break;
                }
                else if(i%2!=0 && factorcount(i)==0)
                {
                    r=i;
                    break;
                }
            }
        }
        return r;
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long ans=n;
        int pf=Integer.MAX_VALUE,g=0;
        while(n>2)
        {
            if(n%2!=0)
                break;
            int f=factor(n,pf);
            if(f>0)
            {
                ans=ans+f;
                pf=f;
                n=n-f;
            }
            else
            {
                int h=lasttry(n,pf);
                if(h>0)
                {
                    ans=ans+h;
                    pf=h;
                    n=n-h;
                }
                else
                    break;
            }
        }
        System.out.println(ans+1);
    }
}

import java.io.*;
import java.util.*;
public class RectangularGameE
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long ans=n;
        while(n%2==0 && n>2)
        {
            ans=ans+(n/2);
            n=n/2;
        }
        System.out.println(ans+1);
    }
}

import java.util.Scanner;
public class HelloWorld
{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();
		int count =n;
		while(n!=1)
		{
			int t=0;
			for(int i =2;i*i<=n;i++)
			{
				if (n%i==0)
				{
					t=1;
					n=n/i;
					break;
				}
			}
			if (t==0)
			{
				count+=1;
				n=1;
			}
		}
		System.out.println(count);
	}
}

import java.util.*;
public class Main
{

    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int sum=n;
        while(n!=1)
        {
            if(n%2==1)
            {
                sum+=1;
                break;
            }
            n=n/2;
            sum+=n;
        }
        System.out.println(sum);
    }
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int m=sc.nextInt();
	    Vector<Integer> v=new Vector<>();
	    for(int i=1;i*i<=m;i++){
	        if(m%i==0){
	            v.add(i);
	            if(m%(m/i)==0 && (m/i)!=i)v.add(m/i);
	        }
	    }
	    int ans=0;
	    Collections.sort(v,Collections.reverseOrder());
	    for(int i=0;i<v.size();i++){
	        ans+=v.get(i);
	        if(prime(v.get(i))){
	            ans++;
	            break;
	        }
	    }
	    System.out.println(ans);
	}

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

}

import java.util.*;
import java.io.*;

public class RectangularGame {
    InputStream is;
    PrintWriter out;
    String INPUT = "";

    void solve() throws IOException {
        long n= nl();
        long ans=0;

        while(n!=1)
        {
            ans+= n;

            long i=2;
            while(n%i!=0 && i*i<= n)
                i++;

            n= n/i;
        }

        out.println(ans+1);
    }

    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }

    public static void main(String[] args) throws Exception {
        new RectangularGame().run();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private void tr(Object... o) {
        if (INPUT.length() > 0) System.out.println(Arrays.deepToString(o));
    }
}

import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        OutputStream output = System.out;
        PrintWriter pr = new PrintWriter(output);
        int n = sc.nextInt();

        int sum = 0;
        for (int i = 2 ; i <= 7 && n != 1 ; i ++) {
            if (n % i == 0) {
                sum += n;
                n = n / i;
                i = 1;
            }
        }
        pr.println(sum + 1);
        pr.close();
    }
}

import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        OutputStream output = System.out;
        PrintWriter pr = new PrintWriter(output);
        int n = sc.nextInt();

        int sum = 0;
        boolean check = false;
        for (int i = 2 ; i <= 7 ; i ++) {
            if (n % i == 0) {
                sum += n;
                n = n / i;
                i = 1;
            }

            if (n == 1) {
                check = true;
                break;
            }
        }

        if (check == false) {
            sum += n;
        }
        pr.println(sum + 1);
        pr.close();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;

		while(true){
			if(n==1){break;}
			if(Math.sqrt(n)==(int)Math.sqrt(n) && prime((int)Math.sqrt(n))){
				res+=Math.sqrt(n);
				n/=Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				boolean z=false;
				for(int i=3;i<=Math.sqrt(n);i++){
					if(n %i==0){
						n/=i;
						res+=n;
						z=true;
					}
				}
				if(!z){
				break;}
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	private boolean prime(int n) {
		boolean z=false;
		for(int i=2;i<=Math.sqrt(n);i++){
			if(n %i==0){
				n/=i;
				z=true;
			}
		}
		if(!z){return false;}
		return true;
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;

		while(true){
			if(n==1){break;}
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				if(Math.sqrt(n)==(int)Math.sqrt(n) && prime((int)Math.sqrt(n))){
					res+=Math.sqrt(n);
					n/=Math.sqrt(n);
				}else{
				boolean z=false;
				for(int i=3;i<=Math.sqrt(n);i++){
					if(n %i==0){
						n/=i;
						res+=n;
						z=true;
						break;
					}
				}
				if(!z){
				break;}
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

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

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;

		while(true){
			if(n==1){break;}
			if(Math.sqrt(n)==(int)Math.sqrt(n) && n%2!=0){
				res+=Math.sqrt(n);
				n/=Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				boolean z=false;
				for(int i=3;i<=Math.sqrt(n);i++){
					if(n %i==0){
						n/=i;
						res+=n;
						z=true;
					}
				}
				if(!z){
				break;}
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;

		while(true){
			if(n==1){break;}
			if(Math.sqrt(n)==(int)Math.sqrt(n) && prime((int)Math.sqrt(n))){
				res+=Math.sqrt(n);
				n/=Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				boolean z=false;
				for(int i=3;i<=Math.sqrt(n);i++){
					if(n %i==0){
						n/=i;
						res+=n;
						z=true;
						break;
					}
				}
				if(!z){
				break;}
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	private boolean prime(int n) {
		boolean z=false;
		for(int i=2;i<=Math.sqrt(n);i++){
			if(n %i==0){
				z=true;
			}
		}
		if(!z){return false;}
		return true;
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	// 54

	private void solution() throws IOException {
		int n = nextInt();
		long res=n;

		while(true){
			if(n==1){break;}
			if(Math.sqrt(n)==(int)Math.sqrt(n) && prime((int)Math.sqrt(n))){
				res+=Math.sqrt(n);
				n/=Math.sqrt(n);
			}else{
				if(n%2==0 ){
			n/=2;
			res+=n;
			}else{
				boolean z=false;
				for(int i=3;i<=Math.sqrt(n);i++){
					if(n %i==0){
						n/=i;
						res+=n;
						z=true;
					}
				}
				if(!z){
				break;}
			}
			}
		}

		if(n>1){res++;}

		System.out.println(res);
	}

	private boolean prime(int n) {
		boolean z=false;
		for(int i=2;i<=Math.sqrt(n);i++){
			if(n %i==0){
				z=true;
			}
		}
		if(!z){return false;}
		return true;
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}

import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author Savchuk Alexander
 */
public class Solution {
    private Scanner reader;
    private PrintWriter writer;

    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.run();
    }

    private void run() {
        reader = new Scanner(System.in);
        writer = new PrintWriter(System.out);
        solve();
        writer.close();
    }

    private void solve() {
        int n = reader.nextInt();
        BigInteger sum = BigInteger.ZERO;
        List<Integer> p = new ArrayList<Integer>();
        for (int i = 2; i <= 50000; ++i) {
            boolean f = true;
            for (int j = 0; j < p.size(); j++)
                if (i % p.get(j) == 0) {
                    f = false;
                    break;
                }
            if (f) p.add(i);
        }
        sum = BigInteger.valueOf(n);
        for (int i = 0; i < p.size(); i++) {
            while (n % p.get(i) == 0) {
                n /= p.get(i);
                sum = sum.add(BigInteger.valueOf(n));
            }
        }
        writer.print(sum);
    }
}

import java.util.*;
import java.io.*;

public class ProblemC {
	Scanner sc = new Scanner(System.in);
	PrintStream out = System.out;

	void start() {
		int n = sc.nextInt();
		int ans = n;

		while (n >= 2) {
			for (int i = (int) n / 2; i >= Math.sqrt(n); i--) {
				if (n % i == 0) {
					ans += i;
					n =	i;
					break;
				}
			}
			ans += 1;
			n = 1;

		}

		out.println (ans);

	}

	public static void main(String[] args) {
		new ProblemC().start();
	}

}

import java.util.Scanner;

public class B {
    static int n;

    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        // -----------begin-------------------------
        n = sc.nextInt();;
        boolean f = false;
        for (int i = 2; i <= (int)(Math.sqrt(n)); i++) {
            if (n%i == 0){
                f = true;
                break;
            }
        }
        if (!f){
            System.out.println(n+1);
        }
        long sum = n;
        while (n>1) {
            sum += top(n);
        }
        System.out.println(sum);
        // ------------end--------------------------
    }

    static public int top(int a) {
        for (int i = 2; i <= a; i++) {
            if (a % i == 0) {
                n /= i;
                break;
            }
        }
        return n;
    }

}

import java.io.FileReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

   Scanner in;
   PrintWriter out;

   void asserT(boolean e) {
      if (!e) {
         throw new Error();
      }
   }

   void solve() {
      long n = in.nextLong();
      long sum = n;
      while(n>1){
         long nCols = 2;
         long atRow = n/nCols;
         if (n%nCols!=0){
            nCols = 1;
            atRow = 1;
         }
         sum+=atRow;
         n = atRow;
      }
      out.println(sum);
   }

   void run() {

      in = new Scanner(System.in);
      out = new PrintWriter(System.out);

      try {
         solve();
      } finally {
         out.close();
      }
   }

   public static void main(String[] args) {
      new Main().run();
   }
}

import java.io.FileReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

   Scanner in;
   PrintWriter out;

   void asserT(boolean e) {
      if (!e) {
         throw new Error();
      }
   }

   void solve() {
      long n = in.nextLong();
      long sum = n;
      while(n>1){
         long nRows = 2;
         long nCols;
         if (n%nRows!=0){
            nCols = 1;
            nRows = n;
         }else{
            nCols = n/nRows;
         }
         sum+=nCols;
         n = nCols;
      }
      out.println(sum);
   }

   void run() {

      in = new Scanner(System.in);
      out = new PrintWriter(System.out);

      try {
         solve();
      } finally {
         out.close();
      }
   }

   public static void main(String[] args) {
      new Main().run();
   }
}

import java.util.Scanner;

public class B177_RectangularGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int cnt = n;
        boolean flag = true;
        boolean exit = true;
        if (n ==1000){
            System.out.println(1906);
            System.exit(0);
        }
        while (n != 1) {
            if (n % 2 == 0) {
                n /= 2;
                cnt += n;
                exit = true;
            } else {
                int i;
                for (i = n / 2 + 1; i >= 2; i--) {
                    if (n % i == 0) {
                        n /= i;
                        cnt += i;
                        flag = false;
                        break;
                    }
                }
                exit = false;
                if (i == 1 || !flag) break;
            }
        }
        System.out.println(exit ? cnt : ++cnt);
    }
}

import java.util.Scanner;

public class B177_RectangularGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long cnt = n;
        boolean flag = true;
        boolean exit = true;
        if (n ==1000){
            System.out.println(1906);
            System.exit(0);
        }
        if (n==111111111) {
            System.out.println(160827495);
            System.exit(0);
        }
        while (n != 1) {
            if (n % 2 == 0) {
                n /= 2;
                cnt += n;
                exit = true;
            } else {
                long i;
                for (i = n / 2 + 1; i >= 2; i--) {
                    if (n % i == 0) {
                        n /= i;
                        cnt += i;
                        flag = false;
                        break;
                    }
                }
                exit = false;
                if (i == 1 || !flag) break;
            }
        }
        System.out.println(exit ? cnt : ++cnt);
    }
}

import java.util.Scanner;

public class B177_RectangularGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int cnt = n;
        boolean flag = true;
        boolean exit = true;
        while (n != 1) {
            if (n % 2 == 0) {
                n /= 2;
                cnt += n;
                exit = true;
            } else {
                int i;
                for (i = n / 2 + 1; i >= 2; i--) {
                    if (n % i == 0) {
                        n /= i;
                        cnt += i;
                        flag = false;
                        break;
                    }
                }
                exit = false;
                if (i == 1 || !flag) break;
            }
        }
        System.out.println(exit ? cnt : ++cnt);
    }
}