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

public class A {
    public static void main(String args[])throws Exception {
        new A().f();
    }
    int MOD = 1000000007;
    void f()throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int dp[][] = new int[n+1][n+1];
        for(int ar[] : dp)
            Arrays.fill(ar, -1);
        for(int i = 1; i <= n; i++) {
            dp[1][i] = i;
            dp[i][1] = 1;
        }
        int x = recur(dp, n, n);
        System.out.println((x+x)%MOD-n);
    }
    int recur(int dp[][], int n, int x) {
        if(dp[n][x] == -1) {
            dp[n][x] = (recur(dp, n-1, x)%MOD + recur(dp, n, x-1)%MOD)%MOD;
        }
        return dp[n][x];
    }
}


/**
 * Created by IntelliJ IDEA.
 * User: aircube
 * Date: 11.01.11
 * Time: 4:14
 * To change this template use File | Settings | File Templates.
 */

import javax.swing.undo.StateEdit;
import java.io.*;
import java.math.*;
import java.util.*;

public class Template {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;

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

    void run() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
        out = new PrintWriter(System.out) ;

        solve();

        br.close();
        out.close();
    }
    static final long mod = 1000000000 + 7;
    int cnt(int x, int d) {
        int r = 0;
        while (x > 0)  {
            r += x / d;
            x /= d;
        }
        return r;
    }
    long bp(long a, long power) {
        long r = 1;
        for(; power > 0; power >>= 1, a = (a * a) % mod) if ((power & 1) > 0) r = (r * a) % mod;
        return r;
    }
    boolean isprime(int x) {
        for(int i = 2; i * i <= x; ++i)
            if (x % i == 0) return false;
        return true;
    }
    long bp(long a, long power) {
        long r = 1;
        for(; power > 0; power >>= 1, a = (a * a) % mod) if ((power & 1) > 0) r = (r * a) % mod;
        return r;
    }
    long inverse(int a) {
        return bp(a, mod - 2);
    }
    void solve() throws  IOException {
        int n = nextInt();
        // (n + n - 1) ! / n ! / (n - 1) !
        long res = 2;
        for(int i = 1; i <= n + n - 1; ++i) {
            res = (res * i) % mod;
        }
        for(int i = 1; i <= n; ++i) {
            res = (res * inverse(i)) % mod;
        }
        for(int i = 1; i <= n - 1; ++i) {
            res = (res * inverse(i)) % mod;
        }
        res -= n;
        res = (res % mod + mod) % mod;
        out.print(res);

    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }
    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}


// package CF1076;

import java.util.Scanner;

public class CF1076B {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n = s.nextLong();
        boolean[] prime = sieveOfEratosthenes((int) n);
//        for (long i = 2; i <= n; i++) {
        int count = 0;
        long ans;
        long m = n;
        if (m % 2 == 0) {
            ans = m / 2;
//                System.out.println(m/2);
        } else {
//            if(!prime[])
//            if(prime)QD
            if (isPrime(m)) {
                ans = 1;
//                    System.out.println(1);
            } else {
                long p = primeFactors(m);
                ans = (m - p) / 2 + 1;
//                    System.out.println((m - 1) / 2);
            }
        }
        System.out.println(ans);
//            while (m != 0) {
//                long div = -1;
//                for (int j = 2; j <= m; j++) {
//                    if(prime[j] && m % j == 0){
//                        div = j;
//                        break;
//                    }
//                }
//                m -= div;
//                count++;
//            }
//            if(ans != count){
//                System.out.println("***"+i);
//                System.out.println(ans + " " + count);
//            }
//        }
//        System.out.println(count);
    }

    public static long primeFactors(long n) {
        // Print the number of 2s that divide n

        while (n % 2 == 0) {
            System.out.print(2 + " ");
            n /= 2;
        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            // While i divides n, print i and divide n
            while (n % i == 0) {
                return i;
            }
        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n > 2)
            return n;

        return -1;
    }

    static boolean[] sieveOfEratosthenes(int n) {
        // Create a boolean array "prime[0..n]" and initialize
        // all entries it as true. A value in prime[i] will
        // finally be false if i is Not a prime, else true.
        boolean prime[] = new boolean[n + 1];
        for (int i = 0; i <= n; i++)
            prime[i] = true;

        for (int p = 2; p * p <= n; p++) {
            // If prime[p] is not changed, then it is a prime
            if (prime[p] == true) {
                // Update all multiples of p
                for (int i = p * 2; i <= n; i += p)
                    prime[i] = false;
            }
        }

        // Print all prime numbers
        return prime;
    }

    static boolean isPrime(long n) {

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


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

public class Main {
public void solve()
{
    int n = nextInt();
    int k = nextInt();
    int res = 0;
    int i = 0;
    int t = 240 - k;
    int array[] = new int[n];
    for (int a = 0; a < n; a++)
    {
        array[a] = (5 * a) + res;
        res = res + (5 * a);
    }
    while (array[i] < t) {
    if (array[i] == t)
    System.out.println(i);
    i++;
    }
     if (array[i] > t)
    System.out.println(i-1);
}
public static void main (String[]args){
new Main().run();
}

BufferedReader br;
StringTokenizer st;
PrintWriter out;

private void run () {
try {
br = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
//br = new BufferedReader(new FileReader("birthday.in"));
//out = new PrintWriter(new FileWriter("birthday.out"));
solve();
br.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}

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

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


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

import static java.lang.Math.*;

public class Main extends PrintWriter {
    BufferedReader in;
    StringTokenizer stok;
    final Random rand = new Random(31);
    final int inf = (int) 1e9;
    final long linf = (long) 1e18;

    public void solve() throws IOException {
        int n = nextInt();
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        int m = a[0].length;
        long[] d1 = new long[1 << m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j) {
                    int x = 0;
                    for (int k = 0; k < m; k++) {
                        if (a[i][k] == a[j][k]) {
                            x |= (1 << k);
                        }
                    }
                    d1[x] |= (1 << i);
                    d1[x] |= (1 << j);
                }
            }
        }
        for (int i = (1 << m) - 1; i >= 0; i--) {
            for (int j = 0; j < m; j++) {
                d1[i] |= d1[i | (1 << j)];
            }
        }
        double[] d = new double[1 << m];
        d[0] = 1;
        for (int mask = 0; mask < (1 << m); mask++) {
            double bc = Integer.bitCount(mask);
            int bc1 = Long.bitCount(d1[mask]);
            if (bc1 == 0) {
                continue;
            }
            for (int i = 0; i < m; i++) {
                if ((mask & (1 << i)) == 0) {
                    int nmask = mask | (1 << i);
                    double nbc1 = Long.bitCount(d1[nmask]);
                    d[nmask] += d[mask] * (nbc1 / bc1) / (m - bc);
                }
            }
        }
        double ans = 0;
        for (int mask = 0; mask < (1 << m); mask++) {
            double finish = 0;
            int bc1 = Long.bitCount(d1[mask]);
            int bc = Long.bitCount(mask);
            for (int i = 0; i < m; i++) {
                if ((mask & (1 << i)) > 0) {
                    int nmask = mask & ~(1 << i);
                    int nbc1 = Long.bitCount(d1[nmask]);
                    if (nbc1 == 0) {
                        continue;
                    }
                    int nbc = Long.bitCount(nmask);
                    finish += d[nmask] * (nbc1 - bc1) / nbc1 / (m - nbc);
                }
            }
            ans += bc * finish;
        }
        printf("%.11f", ans);
    }

    public void run() {
        try {
            solve();
            close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(abs(-1));
        }
    }

    Main() throws IOException {
        super(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    Main(String s) throws IOException {
        super("".equals(s) ? "output.txt" : (s + ".out"));
        in = new BufferedReader(new FileReader("".equals(s) ? "input.txt" : (s + ".in")));
    }

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception ignored) {
        }
        new Main().run();
    }

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

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

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

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

    int[] nextIntArray(int len) throws IOException {
        int[] a = new int[len];
        for (int i = 0; i < len; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    void shuffle(int[] a) {
        for (int i = 1; i < a.length; i++) {
            int x = rand.nextInt(i + 1);
            int t = a[i];
            a[i] = a[x];
            a[x] = t;
        }
    }

    boolean nextPerm(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
            if (p[a] < p[a + 1])
                for (int b = p.length - 1; ; --b)
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
        return false;
    }

    <T> List<T>[] createAdjacencyList(int countVertex) {
        List<T>[] res = new List[countVertex];
        for (int i = 0; i < countVertex; i++) {
            res[i] = new ArrayList<T>();
        }
        return res;
    }
}


import java.util.Scanner;

public class Main {

	public static int  dp(int a,int b){
		if(a<=0|| b<=0)
			return 0;
	//	System.out.println(a+" "+b);
		int rs=Math.max(1+dp(a-2,b+1),1+dp(a+1,b-2));
		return rs;
	}
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int	aa =scan.nextInt();
		int bb=scan.nextInt();
		System.out.println(dp(aa,bb));

	}

}


import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;

public class CF303D {

    static long modPow(long x, long pow, long mod) {
        long r = 1;
        while (pow > 0) {
            if (pow % 2 == 1) {
                r = r * x % mod;
            }
            pow /= 2;
            x = x * x % mod;
        }
        return r;
    }

    public static void solve(Input in, PrintWriter out) throws IOException {
        int n = in.nextInt() + 1;
        int x = in.nextInt() - 1;
        for (int d = 2; d * d <= n; ++d) {
            if (n % d == 0) {
                out.println(-1);
                return;
            }
        }
        ArrayList<Integer> pDivs = new ArrayList<Integer>();
        int m = n - 1;
        for (int d = 2; d * d <= m; ++d) {
            if (m % d == 0) {
                pDivs.add(d);
                while (m % d == 0) {
                    m /= d;
                }
            }
        }
        if (m > 1) {
            pDivs.add(m);
        }
        int b;
        if (n == 2) {
            b = 1;
        } else {
            loop: for (b = 2; ; ++b) {
                for (int p : pDivs) {
                    if (modPow(b, (n - 1) / p, n) == 1) {
                        continue loop;
                    }
                }
                break;
            }
        }
        boolean[] coprime = new boolean[n - 1];
        Arrays.fill(coprime, true);
        for (int p : pDivs) {
            for (int i = 0; i < n - 1; i += p) {
                coprime[i] = false;
            }
        }
        long ans = -1;
        long cur = 1;
        for (int i = 0; i < (n == 2 ? 2 : n - 1); ++i) {
            if (coprime[i]) {
                if (cur <= x) {
                    ans = Math.max(ans, cur + n * ((x - cur) / n));
                }
            }
            cur = cur * b % n;
        }
        out.println(ans);
    }

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

    static class Input {
        BufferedReader in;
        StringBuilder sb = new StringBuilder();

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

        public Input(String s) {
            this.in = new BufferedReader(new StringReader(s));
        }

        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.util.*;
import java.io.*;
public class horapalindroma{
public static void main(String args[]) throws IOException{
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
String tmp = lector.readLine();
int a = Integer.parseInt(tmp.substring(0,tmp.indexOf(":")));
String aa = tmp.substring(0,tmp.indexOf(":"));
int b = Integer.parseInt(tmp.substring(tmp.indexOf(":")+1));
String ra = aa.charAt(1)+""+aa.charAt(0);
if(Integer.parseInt(ra)>b && Integer.parseInt(ra)<60){
System.out.println(aa+":"+ra);
return;
}
a++;
a%=24;
while(true){
String tt = ""+a;
while(tt.length()<2)tt="0"+a;
String rtt = tt.charAt(1)+""+tt.charAt(0);
if(Integer.parseInt(rtt)<60){
System.out.println(tt+":"+rtt);
break;
}
}
}
}


import java.util.Scanner;

public class Demo1 {

	public static void main(String[] args) {
		int n, x;
		Scanner in = new Scanner(System.in);

		n = in.nextInt();

		printNum(n);

	}

	public static void printNum(int n) {
		int a;
		for (int i = 0; i < (n/2); i++) {
			a=(n-1)/2-i;
			if(gcd(a,(n-a))){
				System.out.println(a+" "+(n-a));
				break;
			}
		}
	}

	public static boolean gcd(int a ,int b){                  //a<=b
		boolean result=true;
		for(int i=2;i<=a;i++){
			if(a%i==0&&b%i==0){
				result=false;
				break;
			}
		}
		return result;
	}

}


//package cf667;

import java.io.*;
import java.util.*;
import java.util.stream.Collectors;

public class F {
    static boolean CONSTRUCTIVE = false;
    static long MOD = (long) 1e9 + 7;
    static long BIG = (long) 2e9;

    public static void solve(Reader in, PrintWriter out) {
        int n = in.nextInt();
        int K = in.nextInt();
        char[] arr = in.next().toCharArray();
        String t = in.next();
        char a = t.charAt(0);
        char b = t.charAt(1);

        int[][][] dp = new int[n][K+1][n];

        for (int i = 0; i < n; i++) {
            for (int k = 0; k <= K; k++) {
                for (int j = 0; j < n; j++) {
                    dp[i][k][j] = Integer.MIN_VALUE/2;
                }
            }
        }

        // index, k, as

        // first element
        if (arr[0] == a) {
            dp[0][0][1] = 0;
        } else {
            dp[0][1][1] = 0;
            dp[0][0][0] = 0;
        }

        int max = 0;
        for (int i = 1; i < n; i++) {
            for (int k = 0; k <= K; k++) {
                for (int j = 0; j < n; j++) {
                    int val = dp[i-1][k][j];
                    // do nothing
                    if (arr[i] == a && j > 0) {
                        val = Math.max(val, a==b ? dp[i-1][k][j-1] + j-1 : dp[i - 1][k][j-1]); // get an a for free
                    }
                    if (arr[i] == b) {
                        val = Math.max(val, dp[i - 1][k][j] + j);
                    }

                    // change to a
                    if (k > 0 && j > 0) {
                        val = Math.max(val, a==b ? dp[i-1][k-1][j-1] + j-1 : dp[i - 1][k - 1][j - 1]);
                    }
                    // change to b
                    if (k > 0) {
                        val = Math.max(val, dp[i - 1][k - 1][j] + j);
                    }

                    dp[i][k][j] = val;
                    max = Math.max(max, val);
//                    if (a==b) System.out.printf("(%d %d %d): %d\n", i,k,j,val);
                }
            }
        }

        out.println(max);
    }

    public static void main(String[] args) throws IOException {
        Reader in = null;
        PrintWriter out = null;
        for (String arg : args) {
            if (arg.startsWith("input")) {
                in = new Reader(arg);
            } else if (arg.startsWith("output")) {
                out = new PrintWriter(new FileWriter(arg));
            }
        }
        if (in == null) in = new Reader();
        if (out == null) out = new PrintWriter(new OutputStreamWriter(System.out));

//        int tests = in.nextInt();
//        for (int t = 0; t < tests; t++) {
        solve(in, out);
//        }

        out.flush();
    }

    static class Tester {
        public static void main(String[] args) throws IOException {
            Validator validator = new Validator();

            System.out.println("SAMPLE TESTS:");
            File currentDir = new File(".");
            long before;
            long after;
            for (File inputFile : Arrays.stream(currentDir.listFiles())
                    .sorted(Comparator.comparing(File::getName))
                    .collect(Collectors.toList())) {
                if (!inputFile.getName().matches("input[0-9]")) continue;
                int number = Integer.parseInt(inputFile.getName().substring(5));
                System.out.printf("Test %d: \n", number);

                before = System.nanoTime();
                String outputFileName = "output" + inputFile.getName().substring(5);
                F.main(new String[]{inputFile.getName(), outputFileName});
                after = System.nanoTime();

                File outputFile = new File("output" + number);
                if (!outputFile.exists()) {
                    throw new IllegalStateException("Missing output file " + outputFile);
                }

                // TODO if verifier is implemented, remove this
                if (CONSTRUCTIVE) {
                    System.out.println("INPUT:");
                    printFile(inputFile);
                    System.out.printf("\nOUTPUT: (%d milliseconds)\n", (after - before) / 1000000L);
                    printFile(outputFile);
                    continue;
                }

                if (validator.validate(inputFile, outputFile)) {
                    System.out.printf("OK (%d milliseconds)\n", (after - before) / 1000000L);
                } else {
                    System.out.println("FAILED");
                    System.out.println("\nInput: ");
                    printFile(inputFile);
                    System.out.println("\nIncorrect Output: ");
                    printFile(outputFile);
                    return;
                }
            }
            System.out.println("\n-----------------\n");

            File sightTestInput = new File("input-sight");
            if (sightTestInput.exists()) {
                System.out.println("Running sight test... Input:");
                printFile(sightTestInput);
                before = System.nanoTime();
                System.out.println("\nOutput: ");
                F.main(new String[]{"input-sight"});
                after = System.nanoTime();
                System.out.printf("(%d milliseconds)\n", (after - before) / 1000000L);
                System.out.println("\n-----------------\n");
            }

            File bigTestInput = new File("input-big");
            if (bigTestInput.exists()) {
                System.out.println("Running big test...");
                before = System.nanoTime();
                F.main(new String[] {"input-big"});
                after = System.nanoTime();
                System.out.printf("(%d milliseconds)\n", (after - before) / 1000000L);
            }
        }

        static void printFile(File file) throws FileNotFoundException {
            BufferedReader reader = new BufferedReader(new FileReader(file));
            reader.lines().forEach(System.out::println);
        }
    }

    static class Validator {
        boolean validate(File inputFile, File outputFile) throws IOException {
            int number = Integer.parseInt(inputFile.getName().substring(5));
            File expectedOutputFile = new File("expected-output" + number);
            if (CONSTRUCTIVE || !expectedOutputFile.exists()) {
                return validateManual(inputFile, outputFile);
            }
            return areSame(outputFile, expectedOutputFile);
        }

        private boolean validateManual(File inputFile, File outputFile) throws IOException {
            // OPTION 1: validate against naive solution
//            Naive.main(new String[] {inputFile.getName()})

            // OPTION 2: Validate output against input (typically for constructive problems)
            Reader inputReader = new Reader(inputFile.getName());
            Reader outputReader = new Reader(outputFile.getName());

            // TODO implement manual validation

            throw new IllegalStateException("Missing expected output file");
        }

        private boolean areSame(File file1, File file2) throws IOException {
            BufferedReader reader1 = new BufferedReader(new FileReader(file1));
            BufferedReader reader2 = new BufferedReader(new FileReader(file2));

            String line1;
            while ((line1 = reader1.readLine()) != null) {
                String line2 = reader2.readLine();
                if (line2 == null) line2 = ""; // ok if one has an extra newline
                if (!line1.trim().equals(line2.trim())) {
                    return false;
                }
            }
            String line2;
            while ((line2 = reader2.readLine()) != null) {
                if (!line2.trim().isEmpty()) {
                    return false;
                }
            }
            return true;
        }

    }

    static class Naive {
        public static void solveNaive(Reader in, PrintWriter out) {

        }

        public static void main(String[] args) throws IOException {
            Reader in = null;
            PrintWriter out = null;
            for (String arg : args) {
                if (arg.startsWith("input")) {
                    in = new Reader(arg);
                } else if (arg.startsWith("output")) {
                    out = new PrintWriter(new FileWriter(arg));
                }
            }
            if (in == null) in = new Reader();
            if (out == null) out = new PrintWriter(new OutputStreamWriter(System.out));

            int tests = in.nextInt();
            for (int t = 0; t < tests; t++) {
                solve(in, out);
            }

            out.flush();
            out.close();
        }
    }

    static long pair(int x, int y) {
        return x * BIG + y;
    }

    static int x(long pair) {
        return (int) (pair / BIG);
    }

    static int y(long pair) {
        return (int) (pair % BIG);
    }

    static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public Reader(String fileName) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(fileName));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        public int[] nextInts(int n) {
            int[] out = new int[n];
            for (int i = 0; i < n; i++) {
                out[i] = nextInt();
            }
            return out;
        }

        public long[] nextLongs(int n) {
            long[] out = new long[n];
            for (int i = 0; i < n; i++) {
                out[i] = nextLong();
            }
            return out;
        }
    }
}


import java.util.*;

 public class Solve50{
 	public static void main(String[] args) {

 	Scanner sc=new Scanner(System.in);
 	int m=sc.nextInt();
 	int n=sc.nextInt();
 	int max=0;
 	if (m>=2&&n>=1) {

 	 max=(m*n)/2;
 }
 System.out.println(max);
 }

 }


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

public class sdsad
{
	public static void main(String args[]) throws IOException{
	int noti=0;long index=0;
	int index1=-1;
	int index2=-1;
	Scanner u=new Scanner(System.in);
	int x=0;int i=0;
	x=u.nextInt();
	int arr[]=new int[x];
	for(i=0;i<x;i++)
		{
			arr[i]=u.nextInt();
		}

	HashMap<Integer,Integer> hm=new HashMap<>();
	hm.put(1,2);
	for(i=3;i<151;i++)
	{
		hm.put(i,2*i-1);
	}

	//System.out.println(hm);
	if(x==1 && arr[0]!=0) {System.out.println("BitLGM");}
	else if(x==1 && arr[0]==0){ System.out.println("BitAryo");}
	for(i=0;i<x;i++)
	{
		for(int j=0;j<x-i-1;j++)
		{
			int temp=arr[j];
			if(arr[j]>arr[j+1])
			{
				arr[j]=arr[j+1];
				arr[j+1]=temp;
			}
		}
	}

//	System.out.println(arr[0]);
	//System.out.println(arr[x-1]);
	if(x==2) {
				if(arr[0]==0 && arr[1]!=0) System.out.println("BitLGM");
				else if((arr[0]==0 && arr[1]==0) || (hm.get(arr[0])==arr[1])  ) System.out.println("BitAryo");

				else System.out.println("BitLGM");

			 }

	if(x==3) {
				if(arr[0]%2!=0){
									if(arr[1]==arr[2]) System.out.println("BitAryo");
									else System.out.println("BitLGM");

							   }
				else if(arr[0]==0 && arr[1]!=0 && arr[2]!=0){
					if(hm.get(arr[1])==arr[2]) System.out.println("BitAryo");

					else System.out.println("BitLGM");

				}
				else {
						if((hm.get(arr[1]-(arr[0]-1))+arr[0]-1)==arr[2] || (arr[0]==0 && arr[1]==0 && arr[2]==0)) System.out.println("BitAryo");
						else System.out.println("BitLGM");

					 }

	         }
	}}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class ProblemB_46 {

	final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok=new StringTokenizer("");

	void init() throws FileNotFoundException{
		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");
		}
	}

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

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

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

	public void run(){
		try{
			long t1=System.currentTimeMillis();
			init();
			solve();
			out.close();
			long t2=System.currentTimeMillis();
			System.err.println("Time = "+(t2-t1));
		}catch (Exception e){
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	void solve() throws IOException{
		int a=readInt();
		int b=readInt();
		int max=0;
		char[] aa=Integer.toString(a).toCharArray();
		char[] bb=Integer.toString(b).toCharArray();
		for (int k=0; k<aa.length;k++){
			if (aa[k]-'0'>max) max=aa[k]-'0';
		}
		for (int k=0; k<bb.length;k++){
			if (bb[k]-'0'>max) max=bb[k]-'0';
		}
		String s=Integer.toString(a+b,max+1);
				out.print(s.length());
	}
}


//package com.company;

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

public class Main {
    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int mod = 1_000_000_007;
            long[] powNeq1 = new long[n * n + 1];
            long[] powKn1 = new long[n * n + 1];
            long[] powK = new long[n * n + 1];
            long[][] nChooseK = new long[n + 1][n + 1];
            powNeq1[0] = powKn1[0] = powK[0] = 1;
            for (int i = 1; i < n * n + 1; i++) {
                powNeq1[i] = powNeq1[i - 1] * (mod - 1) % mod;
                powKn1[i] = powKn1[i - 1] * (k - 1) % mod;
                powK[i] = powK[i - 1] * k % mod;
            }
            for (int i = 0; i <= n; i++) {
                nChooseK[i][0] = nChooseK[i][i] = 1;
            }
            for (int i = 2; i <= n; i++) {
                for (int j = 1; j < i; j++) {
                    nChooseK[i][j] = (nChooseK[i - 1][j - 1] + nChooseK[i - 1][j]) % mod;
                }
            }
            long ret = 0;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    int T = n * i + n * j - i * j;
                    ret = (ret + powNeq1[i + j] * powKn1[T] % mod * powK[n * n - T] % mod * nChooseK[n][i] % mod * nChooseK[n][j] % mod) % mod;
                }
            }
            pw.println(ret);

        }
    }

    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("input"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("output"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(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.FileInputStream;
import java.util.Scanner;

public class sol {

  static long m = (long)1e9 + 7;

  static long mod(long x) { return (x % m + m) % m; }
  static long pow(long b, long e) {
    long ans = 1;
    while (e > 0) {
      if ((e & 1) == 1) {
        ans *= b;
        ans %= m;
      }
      b *= b;
      b %= m;
      e >>= 1;
    }
    return ans;
  }
  public static void main(String[] args) {
    Scanner in;
    try {
      in = new Scanner(System.in);
    } catch (Exception e) {
      return;
    }
    int n = in.nextInt(), k = in.nextInt();
    long [][] dp = new long [n + 1][k + 1], C = new long [n + 1][n + 1];

    C[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      C[i][0] = C[i][i] = 1;
      for (int j = 1; j < i; j++) {
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        C[i][j] %= m;
      }
    }

    dp[1][0] = pow(mod(pow(k, n) - pow(k - 1, n)), 1);
    for (int c = 1; c <= n; c++) dp[1][c] = pow(k, n - c);
    for (int r = 2; r <= n; r++) {
      dp[r][0] = pow(mod(pow(k, n) - pow(k - 1, n)), r);
      for (int c = 1; c <= n; c++) {
        dp[r][c] = pow(k - 1, c) * mod(pow(k, n - c) - pow(k - 1, n - c)) % m * dp[r - 1][c] % m;
        for (int c0 = 1; c0 <= c; c0++) {
          dp[r][c] += C[c][c0] * pow(k - 1, c - c0) % m * pow(k, n - c) % m * dp[r - 1][c - c0] % m;
          dp[r][c] %= m;
        }
      }
    }
    System.out.println(dp[n][n]);
  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.util.Random;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            DLinearCongruentialGenerator solver = new DLinearCongruentialGenerator();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class DLinearCongruentialGenerator {
        public int log(int x, int y) {
            int ans = 0;
            while (y != 0 && y % x == 0) {
                ans++;
                y /= x;
            }
            return ans;
        }

        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int limit = (int) 2e6;
            IntegerMultiWayStack primeFactors = Factorization.factorizeRangePrime(limit);
            int[] cnts = new int[limit + 1];
            int[] times = new int[limit + 1];
            int[] xs = new int[n];
            Randomized.shuffle(xs);
            Arrays.sort(xs);
            SequenceUtils.reverse(xs);
            boolean[] retain = new boolean[n];
            in.populate(xs);
            for (int i = 0; i < n; i++) {
                int x = xs[i];
                if (cnts[x] == 0) {
                    retain[i] = true;
                    cnts[x] = 1;
                    times[x] = 1;
                    continue;
                }

                for (IntegerIterator iterator = primeFactors.iterator(x - 1); iterator.hasNext(); ) {
                    int p = iterator.next();
                    int log = log(p, x - 1);
                    if (cnts[p] < log) {
                        cnts[p] = log;
                        times[p] = 0;
                    }
                    if (cnts[p] == log) {
                        times[p]++;
                    }
                }
            }

            Modular mod = new Modular(1e9 + 7);
            int prod = 1;
            for (int i = 1; i <= limit; i++) {
                for (int j = 0; j < cnts[i]; j++) {
                    prod = mod.mul(prod, i);
                }
            }

            for (int i = 0; i < n; i++) {
                int x = xs[i];
                boolean unique = false;
                if (retain[i]) {
                    if (cnts[x] == 1 && times[x] == 1) {
                        unique = true;
                    }
                } else {
                    for (IntegerIterator iterator = primeFactors.iterator(x - 1); iterator.hasNext(); ) {
                        int p = iterator.next();
                        int log = log(p, x - 1);
                        if (cnts[p] == log && times[p] == 1) {
                            unique = true;
                        }
                    }
                }
                if (!unique) {
                    prod = mod.plus(prod, 1);
                    break;
                }
            }

            out.println(prod);
        }

    }

    static class Modular {
        int m;

        public Modular(int m) {
            this.m = m;
        }

        public Modular(long m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public Modular(double m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int plus(int x, int y) {
            return valueOf(x + y);
        }

        public String toString() {
            return "mod " + m;
        }

    }

    static class DigitUtils {
        private DigitUtils() {
        }

        public static boolean isMultiplicationOverflow(long a, long b, long limit) {
            if (limit < 0) {
                limit = -limit;
            }
            if (a < 0) {
                a = -a;
            }
            if (b < 0) {
                b = -b;
            }
            if (a == 0 || b == 0) {
                return false;
            }
            //a * b > limit => a > limit / b
            return a > limit / b;
        }

    }

    static class Randomized {
        public static void shuffle(int[] data) {
            shuffle(data, 0, data.length - 1);
        }

        public static void shuffle(int[] data, int from, int to) {
            to--;
            for (int i = from; i <= to; i++) {
                int s = nextInt(i, to);
                int tmp = data[i];
                data[i] = data[s];
                data[s] = tmp;
            }
        }

        public static int nextInt(int l, int r) {
            return RandomWrapper.INSTANCE.nextInt(l, r);
        }

    }

    static class RandomWrapper {
        private Random random;
        public static RandomWrapper INSTANCE = new RandomWrapper(new Random());

        public RandomWrapper() {
            this(new Random());
        }

        public RandomWrapper(Random random) {
            this.random = random;
        }

        public int nextInt(int l, int r) {
            return random.nextInt(r - l + 1) + l;
        }

    }

    static class IntegerMultiWayStack {
        private int[] values;
        private int[] next;
        private int[] heads;
        private int alloc;
        private int stackNum;

        public IntegerIterator iterator(final int queue) {
            return new IntegerIterator() {
                int ele = heads[queue];

                public boolean hasNext() {
                    return ele != 0;
                }

                public int next() {
                    int ans = values[ele];
                    ele = next[ele];
                    return ans;
                }
            };
        }

        private void doubleCapacity() {
            int newSize = Math.max(next.length + 10, next.length * 2);
            next = Arrays.copyOf(next, newSize);
            values = Arrays.copyOf(values, newSize);
        }

        public void alloc() {
            alloc++;
            if (alloc >= next.length) {
                doubleCapacity();
            }
            next[alloc] = 0;
        }

        public boolean isEmpty(int qId) {
            return heads[qId] == 0;
        }

        public IntegerMultiWayStack(int qNum, int totalCapacity) {
            values = new int[totalCapacity + 1];
            next = new int[totalCapacity + 1];
            heads = new int[qNum];
            stackNum = qNum;
        }

        public void addLast(int qId, int x) {
            alloc();
            values[alloc] = x;
            next[alloc] = heads[qId];
            heads[qId] = alloc;
        }

        public String toString() {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < stackNum; i++) {
                if (isEmpty(i)) {
                    continue;
                }
                builder.append(i).append(": ");
                for (IntegerIterator iterator = iterator(i); iterator.hasNext(); ) {
                    builder.append(iterator.next()).append(",");
                }
                if (builder.charAt(builder.length() - 1) == ',') {
                    builder.setLength(builder.length() - 1);
                }
                builder.append('\n');
            }
            return builder.toString();
        }

    }

    static class MinimumNumberWithMaximumFactors {
        private static int[] primes = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

        public static long[] maximumPrimeFactor(long n) {
            long[] ans = new long[2];
            ans[0] = 1;
            for (int i = 0; i < primes.length; i++) {
                if (DigitUtils.isMultiplicationOverflow(ans[0], primes[i], n)) {
                    break;
                }
                ans[0] *= primes[i];
                ans[1]++;
            }
            return ans;
        }

    }

    static class Factorization {
        public static IntegerMultiWayStack factorizeRangePrime(int n) {
            int maxFactorCnt = (int) MinimumNumberWithMaximumFactors.maximumPrimeFactor(n)[1];
            IntegerMultiWayStack stack = new IntegerMultiWayStack(n + 1, n * maxFactorCnt);
            boolean[] isComp = new boolean[n + 1];
            for (int i = 2; i <= n; i++) {
                if (isComp[i]) {
                    continue;
                }
                for (int j = i; j <= n; j += i) {
                    isComp[j] = true;
                    stack.addLast(j, i);
                }
            }
            return stack;
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class SequenceUtils {
        public static void swap(int[] data, int i, int j) {
            int tmp = data[i];
            data[i] = data[j];
            data[j] = tmp;
        }

        public static void reverse(int[] data, int l, int r) {
            while (l < r) {
                swap(data, l, r);
                l++;
                r--;
            }
        }

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

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        public void populate(int[] data) {
            for (int i = 0; i < data.length; i++) {
                data[i] = readInt();
            }
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static interface IntegerIterator {
        boolean hasNext();

        int next();

    }
}


package practise;
import java.io.*;
public class lucky_sub {
public static void main(String arg[])throws java.lang.Exception
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	String str;
	str=br.readLine();
	char[]chr=new char[100];
	chr=str.toCharArray();
	int[]arr=new int[10];
	int i,temp;
	for(char ch:chr)
	{
		temp=(int)ch;
		temp=temp-48;
		arr[temp]++;
	}
	int res=-1;
	if(arr[4]>=arr[7]&&arr[4]>0)
	{
		res=4;
	}
	else if(arr[7]>0)
	{
		res=7;
	}
	System.out.println(res);
}
}


import java.util.Scanner;

/**
 *
 * @author Mostafa POP
 */
public class Codeforces {

    /**
     * @param args the command line arguments
     */
    public static int NightattheMuseum(String text,String n){
        int counter=0,current=0,front=0,reverse=0,sum=0;
        for(int i=0;i<n.length();i++){
            int num=text.indexOf(n.charAt(i));
         front=Math.abs(num-current);
         System.out.println(n.charAt(i)+"front "+front);
        reverse=Math.abs(text.length()-front);
        System.out.println("reverse "+reverse);
        if(front>reverse){
            counter=reverse;

        }
        else{
            counter=front;
        }
        current=num;
        System.out.println("counter "+counter);
        sum+=counter;
            System.out.println("sum "+sum);
        }
        return sum;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String n=sc.next();
        String h="abcdefghijklmnopqrstuvwxyz";
        System.out.println(NightattheMuseum(h,n));
    }


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author @zhendeaini6001
 */
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);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
     public final long MOD = 1000000007;
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        String a = in.next();
        String b = in.next();
        long[][] dp = new long[5001][5001];
        ArrayUtils.fill(dp, 0);
        for (int i = 0; i < a.length(); ++i){
            for (int j = 0; j < b.length(); ++j){
                if (j >= 1){
                    dp[i][j] = dp[i][j - 1];
                }
                if (a.charAt(i) == b.charAt(j)){
                    ++dp[i][j];
                    if (i >= 1 && j >= 1){
                        dp[i][j] += dp[i-1][j-1];
                    }
                    dp[i][j] %= MOD;
                }
            }
        }
        long res = 0;
        for (int i = 0; i < a.length(); ++i){
            res += dp[i][b.length() - 1];
            res %= MOD;
        }
        out.println(res);
        return;
    }
}

class ArrayUtils {

    public static void fill(long[][] array, long value) {
        for (long[] row : array)
            Arrays.fill(row, value);
    }

    }


import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class C {

    int INF = 1 << 28;
    long P = 1000000009;

    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        long[][] dp = new long[s.length()][t.length()];
        for(int i=0;i<t.length();i++) if(s.charAt(0) == t.charAt(i)) dp[0][i] = (dp[0][i]+1)%P;
        for(int i=1;i<s.length();i++) {
            long sum = 0;
            for(int j=0;j<t.length();j++) {
                if( s.charAt(i) == t.charAt(j) ) {
                    dp[i][j] = (dp[i][j]+sum+1)%P;
                }
                if(s.charAt(i-1) == t.charAt(j)) sum = (sum+dp[i-1][j])%P;
            }
        }
        long sum = 0;
        for(int i=0;i<s.length();i++) for(int j=0;j<t.length();j++){
            sum = (sum+dp[i][j])%1000000009;
        }
        System.out.println(sum);
    }

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


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

public class C {
  FastScanner in;
  PrintWriter out;

  public void solve() throws IOException {
    int[] powCnt = new int[63];
    int[] other = new int[63];
    long[] pows = new long[63];
    pows[0] = 1L;
    for (int i = 1; i < 63; i++) {
      pows[i] = pows[i - 1] * 2;
    }

    int n = in.nextInt();
    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = in.nextLong();
      boolean isPow = false;
      for (int j = 0; j < 63; j++) {
        if (a[i] == pows[j]) {
          powCnt[j]++;
          isPow = true;
        }
        if (!isPow && j != 0 && a[i] > pows[j - 1] && a[i] < pows[j]) {
          other[j]++;
        }
      }
    }

    int min = Arrays.stream(other).sum();
    int max = powCnt[0];
    boolean exists = false;
    for (int len = min; len <= max; len++) {
      int tails = 0;
      int cur = len;
      for (int i = 0; i < 63; i++) {
        tails += other[i + 1];
        int oldCur = cur;
        if (powCnt[i] < cur) {
          cur = powCnt[i];
        }
        int ended = oldCur - cur;
        if (tails < ended) {
          tails = 0;
        } else {
          tails -= ended;
        }
        tails += powCnt[i] - cur;
      }
      if (tails == 0) {
        out.print(len + " ");
        exists = true;
      }
    }
    if (!exists) {
      out.println(-1);
    } else {
      out.println();
    }
  }

  public void run() {
    try {
      in = new FastScanner(System.in);
      out = new PrintWriter(System.out);
      solve();

      out.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    FastScanner(InputStream is) {
      br = new BufferedReader(new InputStreamReader(is));
    }

    String next() {
      while (st == null || !st.hasMoreTokens()) {
        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());
    }
  }

  public static void main(String[] arg) {
    new C().run();
  }
}


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

public class C {
  FastScanner in;
  PrintWriter out;

  public void solve() throws IOException {
    int[] powCnt = new int[63];
    int[] other = new int[63];
    long[] pows = new long[63];
    pows[0] = 1L;
    for (int i = 1; i < 63; i++) {
      pows[i] = pows[i - 1] * 2;
    }

    int n = in.nextInt();
    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = in.nextLong();
      boolean isPow = false;
      for (int j = 0; j < 63; j++) {
        if (a[i] == pows[j]) {
          powCnt[j]++;
          isPow = true;
        }
        if (!isPow && j != 0 && a[i] > pows[j - 1] && a[i] < pows[j]) {
          other[j]++;
        }
      }
    }

    int min = Arrays.stream(other).sum();
    int max = powCnt[0];
    boolean exists = false;
    for (int len = min; len <= max; len++) {
      int tails = 0;
      int cur = len;
      for (int i = 0; i < 62; i++) {
        tails += other[i + 1];
        int oldCur = cur;
        if (powCnt[i] < cur) {
          cur = powCnt[i];
        }
        int ended = oldCur - cur;
        if (tails < ended) {
          tails = 0;
        } else {
          tails -= ended;
        }
        tails += powCnt[i] - cur;
      }
      if (tails == 0) {
        out.print(len + " ");
        exists = true;
      }
    }
    if (!exists) {
      out.println(-1);
    } else {
      out.println();
    }
  }

  public void run() {
    try {
      in = new FastScanner(System.in);
      out = new PrintWriter(System.out);
      solve();

      out.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    FastScanner(InputStream is) {
      br = new BufferedReader(new InputStreamReader(is));
    }

    String next() {
      while (st == null || !st.hasMoreTokens()) {
        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());
    }
  }

  public static void main(String[] arg) {
    new C().run();
  }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Burning_Midnight_Oil_CF {
	static int mini = -1;
	static int k =-1;
	static int n =-1;
	static void binarySearch(int [] a, int min ,int max){
		if(min<=max){
			int mid = (min+max)>>1;
		    int x = a[mid];
		    int z=x;
		    int sum=x;
		    int i =1;
		    while(z>0){
		    	z=(int) (x/Math.pow(k, i));
		    	sum +=  z;
		    	i++;
//		    	System.out.println(sum);
		    }
//		    System.out.println(sum);
		    if(sum<n){
		    	binarySearch(a,mid+1,max);
		    }
		    else{
		    	if(mini>mid||mini==-1)
		    		mini=mid;
		    	binarySearch(a, min,mid-1);
		    }

		}

	}

	public static void main(String[] args) throws Exception {
		InputStreamReader in = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(in);
		String[] x = br.readLine().split(" ");
		n = Integer.parseInt(x[0]);
		k = Integer.parseInt(x[1]);
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = i+1;
		binarySearch(a, 0, n);
		System.out.println(mini+1);

	}

}


package helloworld;
import java.io.*;
import java.util.*;

import helloworld.cd.Scanner;
public class Try {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		PrintWriter out =new PrintWriter (System.out);
		int n=sc.nextInt();
		int []a=new int[n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		long min=(long)Double.POSITIVE_INFINITY;
        for(int i=0;i<n;i++) {
        	int y=i; long tr=0;
        	for(int j=0;j<n;j++) {
        		int l=0;
        		int p=1;
        		l=Math.abs(i-j)+j+i;
        		//System.out.println(l);
        		p=a[j]*l*2;
        		tr+=p;
        		//System.out.println(tr+"j");
        	}
        	if(tr<min)
        		min=tr;
        }
        out.println(min);
        out.flush();
	}
	static	class Scanner{
        StringTokenizer st;
        BufferedReader br;
        public Scanner(InputStream system) {br = new BufferedReader(new InputStreamReader(system));}
        public Scanner(String file) throws Exception {br = new BufferedReader(new FileReader(file));}
        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public String nextLine()throws IOException{return br.readLine();}
        public int nextInt() throws IOException {return Integer.parseInt(next());}
        public double nextDouble() throws IOException {return Double.parseDouble(next());}
        public char nextChar()throws IOException{return next().charAt(0);}
        public Long nextLong()throws IOException{return Long.parseLong(next());}
        public boolean ready() throws IOException{return br.ready();}
        public void waitForInput() throws InterruptedException {Thread.sleep(3000);}
    }
}


import static java.lang.Math.abs;

public class TheFairNutAndElevator implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(System.out);

    public void solve() {
        int n = in.ni();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = in.ni();
        }
        int result = Integer.MAX_VALUE;
        for (int start = 1; start <= n; start++) {
            int current = 0;
            for (int i = 1; i <= n; i++) {
                int power = 2 * (abs(start - i) + (i - 1) + (start - 1));
                current += power * x[i - 1];
            }
            if (current < result) {
                result = current;
            }
        }
        out.println(result);
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) throws IOException {
        try (TheFairNutAndElevator instance = new TheFairNutAndElevator()) {
            instance.solve();
        }
    }
}


import java.util.*;
public class Vitya{

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

        int n = in.nextInt();
        int[] arr = new int[n];

        if(n > 1){
            for(int i = 0; i < n; i++){
                arr[i] = in.nextInt();
            }

            if(arr[n-1] == 15){
                System.out.println("DOWN");
            }

            else if(arr[n-1] == 0){
                System.out.println("UP");
            }

            else {
               if(arr[n-1] - arr[n-2] > 0)
                   System.out.println("UP");

               else
                   System.out.println("DOWN");

            }
        }

        else if (n == 1){
            int tmp = in.nextInt();

            if(tmp == 0)
                System.out.println("UP");

            else if(tmp == 15)
                System.out.println("DOWN");

            else
                System.out.println("-1");

        }
    }//main
}//class

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

        int n = in.nextInt();
        int[] arr = new int[n];

        for(int i = 0; i < n; i++){
            arr[i] = in.nextInt();
        }

        int b = arr[n-1];

        if (b == 0)
            UP
        else if (b == 15)
            DOWN
        else if (n == 1)
            UNKNOWN
        else {
            a = arr[n-2];
            if (b > a)
                UP
            else
                DOWN
        }
    }//main


import java.util.Scanner;

public final class TextVolume
{
	public static void main(String[] argS)
	{
		Scanner sc = new Scanner(System.in);
     		//int T = sc.nextInt();
     		int N = sc.nextInt();
     		//sc.next();

     		String S = sc.nextLine()
     		.trim()
     		;

     		int result=0;
     		int v=0;
     		//for(char c : S.toCharArray())
     		//int n =
     		for(int i = 0, n = S.length() ; i < n ; i++)
     		{
				char c = S.charAt(i);
				if (Character.isWhitespace(c)) //if (c == ' ')  //
				{
					if (v > result) result = v;

					v = 0;
				}
				else if (Character.isUpperCase(c))
					v++;
				else
				{
				}
		     }

		if (v > result) result = v;

		System.out.print(result);
     		sc.close();

	}
}


import java.util.*;
import java.lang.Integer;
public class HelloWorld{

     public static void main(String []args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = n + "";
        int ans = 20;
        for(int i = 1; i < (1<<s.length()); i++) {
            String temp = "";
            int count = s.length();
            for(int j = 0; j < s.length(); j++) {
                if(((1<<j) & i) > 0) {
                    temp += s.charAt(j);
                    count--;
                }
            }
            int num = Integer.parseInt(temp);
            double sqrt = Math.sqrt(num);
            double diff = sqrt - (int)sqrt;
            if(diff < 1e-15) {
                ans = ans < count ? ans : count;
                //System.out.println(num + " " + count);
            }
            ..System.out.println(temp);

        }
        System.out.println(ans != 20 ? ans : -1);
     }
}


import java.util.*;
public class Main{
    public static void main(String[] args) {
       Scanner in=new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int con = 0;
        ArrayList<Integer> h = new ArrayList();
        for (int i = 1; i <= n; i++) {
            h.add(i);
        }
        for (int i = 0; con != 1; i++) {
            if (m > 0) {
                for (int j = 0; j < h.size(); j++) {
                     if (h.get(j) <= m) {
                        m -= h.get(j);
                    } else {
                        con++;
                        break;
                    }
                }
            }
        }
        System.out.println(m);

    }
}


//package codeforces.round520div1;

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);
		}
	}

	public static void main(String args[]) throws Exception {
		new Thread(null, new Ques1(), "Main", 1 << 26).start();
	}

	public void run() {
		InputReader s = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);

		int n=s.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();
		}
		int l=0,r=n;
		int ans=Integer.MIN_VALUE;
		while(l<=r)
		{
			int mid=(l+r)/2;
			if(isValid(arr,n,mid))
			{
				ans=mid;
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		w.println(ans);
		w.close();
	}

	private boolean isValid(int[] arr,int n, int mid) {
		for(int i=mid;i<arr.length;i++)
		{
			if(i==mid)
			{
				if(arr[i]-1==mid)
					return true;
			}
			else
			{
				if(arr[i]-arr[i-mid-1]-1==mid)
				{
					return true;
				}
			}
		}
		if(n-mid-1>=0)
		if(1000-arr[n-mid-1]==mid)
			return true;
		return false;
	}
}


import java.util.*;
public class tatti{

          public static void main(String dsgs[]){
                    Scanner s = new Scanner(System.in);
                    int n;
                    n = s.nextInt();
                    int a[] =new int[n];
                    for(int i=0;i<n;i++){
                              a[i] = s.nextInt();
                    }
                    int max =Integer.MAX_VALUE;
                    int x=0;y=0;
                    for(int i=0;i<n;i++){
                              for(int j=i+1;j<n;j++){
                                        if(max<(a[i]-a[j])){
                                                  x = i;
                                                  y = j;
                                                  max = a[i]-a[j];
                                        }
                              }
                    }
                    int temp = a[x];
                    a[x] = a[0];
                    a[0] = temp;
                    temp = a[n-1];
                    a[n-1] = a[y];
                    a[y] = temp;
                    Arrays.sort(a,1,n-1);
                    for(int i=0;i<n;i++)
                              System.out.println(a[i]+" ");
          }
}


package javaapplication2;

import java.util.Scanner;
public class test1 {
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int n =sc.nextInt();
        int k= sc.nextInt();
        for (int i=1;i<=k;i++){
            if (n%10==0){
                n=n/10;
            }else {
                n=n-1;
            }
        }
        System.out.println(n);
    }
}


import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d = in.nextInt();
		int n = in.nextInt();
		boolean hash[] = new boolean[100002];
		int k = 1;
		while (k <= n) {
			hash[k * a] = true;
			hash[k * b] = true;
			hash[k * c] = true;
			hash[k * d] = true;
			if (k * a > n && b * b > n && c * k > n && d * k > n) {
				break;
			}
			k++;
		}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			if (hash[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


import java.util.Scanner;
public class CF513A {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n1 = scan.nextInt();
		int n2 = scan.nextInt();
		int k1 = scan.nextInt();
		int k2 = scan.nextInt();
		while (k1 >= 0 && k2 >= 0) {
			if (n1 >= 0 && n2 >= 0) {
				n1--; n2--; k1--; k2--;
			}
		}
		if (n1 > n2) System.out.println("First");
		else System.out.println("Second");
		scan.close();
	}
}


import java.util.Scanner;

public class Test {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String time = in.next();
        int n = in.nextInt();
        int arr[] = new int[5];
        String hourstr = time.charAt(0) + "" + time.charAt(1);
        String minstr = time.charAt(3) + "" + time.charAt(4);

        int hour = Integer.parseInt(hourstr);
        int min = Integer.parseInt(minstr);

        int div = n / 60;
        int rem = n % 60;

        String[] hoursArr = {"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"};

        //System.out.println(div);
        if (min + rem < 60) {
            if (min + rem > 9) {
                System.out.println(hoursArr[(hour + div) % 24] + ":" + (min + rem));

            } else {
                System.out.println(hoursArr[(hour + div) % 24] + ":" + hoursArr[(min + rem) % 60]);

            }
        } else if (min + rem >= 60) {
            hour += (min + rem) / 60;
            System.out.println(hoursArr[(hour + div) % 24] + ":" + hoursArr[(min + rem) % 60]);
        }

    }
}


/*
Keep solving problems.
*/

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

public class CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final long MOD = 1000 * 1000 * 1000 + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "Yes";
    private static final String no = "No";

    long res = 0;
    void solve() throws IOException {
        long x = nextLong();
        long y = nextLong();
        helper(x, y);
        outln(res);
    }

    void helper(long x, long y) {
        if (y == 0) {
            return;
        }
        if (isPrime(x)) {
            res += y / x + y % x;
            return;
        }

        long g = gcd(x, y);
        helper(x / g, y / g);
    }

    boolean isPrime(long x) {
        for (long i = 2; i * i <= x; i++) {
            if (x % i == 0) {
                return false;
            }
        }

        return true;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }

    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }

    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    private void formatPrint(double val) {
        System.out.format("%.9f%n", val);
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    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());
    }
}


import java.util.Scanner;

public class test {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		StringBuilder foo = new StringBuilder("");

		int n = scanner.nextInt();

		for(int i = 1; i <= n; i++) {
			foo.append(i);

		}

		System.out.println(foo.length());

	}

}


import java.util.Scanner;

public class VanyaAndBooks {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        StringBuilder sb = new StringBuilder();

        for (int i = 1; i <= n; i++) {
            sb.append(i);
        }

        System.out.println(sb.length());

    }

}


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

public class P172D {

  final int MAX_VALUE = 10_000_000;
  final int MAX_P = (int)Math.sqrt(MAX_VALUE);
/*
  class Pair implements Comparable {
    public int p, k;
    private long val;

    Pair(int k, int p) {
      this.p = p;
      this.k = k;
      val = p * p * k;
    }

    @Override
    public int compareTo(Object o) {
      return (val - r)o).(
    }

    @Override
    public String toString() {
      return ("<" + k + ", " + p + ">");
    }
  }
*/

  @SuppressWarnings("unchecked")
  public void run() throws Exception {
    int a = nextInt();
    int n = nextInt();
    long total = 0;

long s = new Date().getTime();
    HashMap<Integer, Integer> hm = new HashMap();
    for (int p = 2; p <= MAX_P; p++) {
      int p2 = p * p;
      int kf = MAX_VALUE / p2;
      for (int k = kf; k >= 1; k--) {
        hm.put(k * p2, p);
      }
    }

    System.out.println(hm.size());
//    System.out.println(hm);
    System.out.println((new Date().getTime() - st));

//  println(total);
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P172D().run();
    br.close();
    pw.close();
  }

  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { println("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(""); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }
}


import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    static class Assert {
        static void check(boolean e) {
            if (!e) {
                throw new Error();
            }
        }
    }

    class Scanner {

        StreamTokenizer in;

        Scanner(InputStream is) {
            in = new StreamTokenizer(new InputStreamReader(is));
            in.resetSyntax();
            in.whitespaceChars(0, 32);
            in.wordChars(33, 255);
        }

        String next() {
            try {
                in.nextToken();
                Assert.check(in.ttype == in.TT_WORD);
                return in.sval;
            } catch (IOException e) {
                throw new Error(e);
            }
        }

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

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

    Scanner in;
    PrintWriter out;

    void run() {
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
        try {
            solve();
        } finally {
            out.close();
        }
    }

    void fillPrime(int n) {
        boolean[] boolPrime = new boolean[n + 1];
        ArrayList<Integer> a[] = new ArrayList[n + 1];
        for (int i = 0; i <= n; i++) {
            a[i] = new ArrayList<Integer>();
        }

        Arrays.fill(boolPrime, true);
        for (int i = 2; i <= n; i++) {
            if (boolPrime[i]) {
                a[i].add(i);
                for (int j = 2 * i; j <= n; j += i) {
                    a[j].add(i);
                    boolPrime[j] = false;
                }
            }
        }
    }

    void solve() {
        fillPrime(10000000);

    }
}


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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String n = sc.next();
    int size = 0;
    if (n.charAt(0) == '-') {
      size = n.length()-1;
    } else {
      size = n.length();
    }

    if (size <= 5) {
      short s = Short.parseShort(n);
      if (s > 127 || s < -128) {
        System.out.println("short");
      } else {
        System.out.println("byte");
      }
      return;
    }
    if (size <= 10) {
      int i = Integer.parseInt(n);
      if (i > 32767 || i < -32768) {
        System.out.println("int");
      } else {
        System.out.println("byte");
      }
      return;
    }
    if (size < 19) {
      long l = Long.parseLong(n);
      if (l > 2147483647 || l < -2147483648) {
        System.out.println("int");
      } else {
        System.out.println("long");
      }
      return;
    }
    if (size == 19) {
      BigInteger bi = new BigInteger(n);
      BigInteger lub = new BigInteger("9223372036854775807");
      BigInteger llb = new BigInteger("-9223372036854775808");
      if (bi.compareTo(lub) == 1 || bi.compareTo(llb) == -1) {
        System.out.println("BigInteger");
      } else {
        System.out.println("long");
      }
      return;
    }

    System.out.println("BigInteger");
  }
}


/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public final class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner ob = new Scanner(System.in);
		int a1 = ob.nextInt();
		int a2 = ob.nextInt();
		int k1 = ob.nextInt();
		int k2 = ob.nextInt();
		int n = ob.nextInt();
		int kb,ks,ab,as;
		if(k1>k2){
			kb = k1;
			ks = k2;
			ab = a1;
			as = a2;
		}
		else{
			ks = k1;
			kb = k2;
			as = a1;
			ab = a2;
		}
		int max=0,min=0;
		if(n<ks*as){
			max += n/ks;
		}
		else{
			max += as+Math.min((n-as*ks)/kb,ab);
		}

		int t1=n-ab*(kb-1)-as*(ks-1);
		if(t1>0)
		min += Math.min(t1,as);

		System.out.println(min+" "+max);
	}
}/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner ob = new Scanner(System.in);
		int a1 = ob.nextInt();
		int a2 = ob.nextInt();
		int k1 = ob.nextInt();
		int k2 = ob.nextInt();
		int n = ob.nextInt();
		int kb,ks,ab,as;
		if(k1>k2){
			kb = k1;
			ks = k2;
			ab = a1;
			as = a2;
		}
		else{
			ks = k1;
			kb = k2;
			as = a1;
			ab = a2;
		}
		int max=0,min=0;
		if(n<ks*as){
			max += n/ks;
		}
		else{
			max += as+Math.min((n-as*ks)/kb,ab);
		}

		int t1=n-ab*(kb-1)-as*(ks-1);
		if(t1>0)
		min += Math.min(t1,as);

		System.out.println(min+" "+max);
	}
}


//package bubblecup9f;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

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

	void solve()
	{
		int n = ni(), c0 = ni(), c1 = ni();
		if(c0 > c1){
			int d = c0;c0 = c1; c1 = d;
		}
		if(c0 == 0){
			out.println((long)c1*(n-1));
			return;
		}

		long low = -1, high = 1000000000L;
		while(high - low > 1){
			long h = high+low>>1; // sup of split node's cost
			long eled = 0;
			for(long nc1 = 0;h-nc1*c1 >= 0;nc1++){
				long nc0 = (h-nc1*c1)/c0;
				// C(nc1+0,nc1)+C(nc1+1,nc1)+...+(nc1+nc0,nc0) # eliminated nodes
				// C(nc1+nc0+1,nc0+1)
				eled += roughC(nc1+nc0+1,nc1+1,18);
				if(eled > n-1)break;
			}
			if(eled >= n-1){
				high = h;
			}else{
				low = h;
			}
		}

		{
			long ret = (long)(c0+c1)*(n-1); // # branch
			long eled = 0;
			for(long nc1 = 0;low-nc1*c1 >= 0;nc1++){
				long nc0 = (low-nc1*c1)/c0;
				// C(nc1+0,nc1)+C(nc1+1,nc1)+...+(nc1+nc0,nc1) # eliminated nodes
				// C(nc1+nc0+1,nc1+1)
				long val = roughC(nc1+nc0+1,nc1+1,18);
				eled += val;
				// none 0
				// C(nc1+0,nc1)*nc1*c1+C(nc1+1,nc1)*(c0+nc1*c1)+...+(nc1+nc0,nc1)*(nc0*c0+nc1*c1) # eliminated nodes
				// C(nc1+nc0+1,nc1+1)-C(nc1+k,nc1+1)
				// nc0*C(nc1+nc0+1,nc1+1)-C(nc1+nc0+1,nc1+1+1)
				// c1*val*nc1 + c0*(val*(nc0+1)-val)
				ret += c1*nc1*val + c0*(nc0*val-roughC(nc1+nc0+1,nc1+2,18));
			}
			long rem = n-1-eled;
			ret += rem * (low+1);
			out.println(ret);
		}
	}

	public static long roughC(long n, long r, double lim)
	{
		if(n < r || r < 0 || n < 0)return 0;
		if(r > n/2)r = n - r;
		if(r == 0)return 1;
		double logc = (n+0.5)*Math.log10(n)+(-r-0.5)*Math.log10(r)+(-n+r-0.5)*Math.log10(n-r)-Math.log10(2*Math.PI)/2;
		if(logc >= lim)return Long.MAX_VALUE/2;
		long x = 1;
		for(int i = 0;i < r;i++) {
			x *= n-i;
			x /= i+1;
		}
		return x;
	}

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

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

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

	private byte[] inbuf = new byte[1024];
	private 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 boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.IOException;
import java.math.BigInteger;
import java.util.InputMismatchException;

public class CowsAndPrimitiveRoots {
    public static void main(String[] args) {
        FasterScanner sc = new FasterScanner();

        int P = sc.nextInt();

        int cnt = 0;
        outer:
        for (int x = 1; x < P; x++) {
        	for (int i = 1; i <= P - 2; i++) {
        		if (modPow(x, i, P) == 1) {
        			continue outer;
        		}
        	}
        	if (modPow(x, P - 1, P) == 1) {
        		cnt++;
        	}
        }
        System.out.println(cnt);
    }

    public static long modPow(long b, long e, long m) {
    	return BigInteger.valueOf(b).modPow(BigInteger.valueOf(e), BigInteger.valueOf(m)).longValue();
    }

	public static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

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

		public String nextLine() {
			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 nextString() {
			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 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 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 int[] nextIntArray(int n) {
	        return nextIntArray(n, 0);
	    }

	    public int[] nextIntArray(int n, int off) {
	    	int[] arr = new int[n + off];
	    	for (int i = 0; i < n; i++) {
	    		arr[i + off] = nextInt();
	    	}
	    	return arr;
	    }

	    public long[] nextLongArray(int n) {
	    	return nextLongArray(n, 0);
	    }

		public long[] nextLongArray(int n, int off) {
		    long[] arr = new long[n + off];
		    for (int i = 0; i < n; i++) {
		        arr[i + off] = nextLong();
		    }
		    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;
		}
	}
}


import java.util.Scanner;

/**
 * Created by s326lab on 18/11/2017.
 * http://codeforces.com/problemset/problem/876/A
 */
public class TripForMeal {
    Scanner read= new Scanner(System.in);
    public static void main(String[] args) {
        TripForMeal p = new TripForMeal();
        byte eatVisit = p.readByte();
        byte a = p.readByte();
        byte b = p.readByte();
        byte c = p.readByte();
        int answer = p.tripForMeal(eatVisit, a, b, c);
        System.out.println(answer);
    }
    private int tripForMeal(byte eat, byte a, byte b, byte c){
        int result = 0;
        if (eat ==1){
            return 0;
        }
        while (eat != 1){
            if (a < b) {
                result += a;
                eat--;
                if (c < (a + b)) {
                    result += c;
                    eat--;
                }
            }else {
                result += b;
                eat--;
                if (c < (a + b)) {
                    result += c;
                    eat--;
                }
            }
        }
        return result;
    }//tripForMeal

    private byte readByte(){
        byte result = 0;
        try {
            while (result > 100 | result < 1) {
                result = Byte.parseByte(read.nextLine());
                if (result > 100 || result <1){
                    System.out.println("Enter the value again.");
                }
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return result;
    }//readByte

}//class


import java.util.*;
public class codeforce{
    public static void main(String[] args){
        int l =sc.nextInt();
        int r = sc.nextInt();
        int a =sc.nextInt();
        int k = Math.abs(l-r);
        if(l<r&&a<=k){
            l += a;
            a=0;
        }else if(r<l&&a<=k){
            r += a;
            a=0;
        }else if(r==l){}
        else if(l<r){
            l += k;
            a -= k;
        }else{
            r += k;
            a -= k;
        }
        if(a>0){
            l += a/2;
            r += a/2;
        }
        System.out.println(Math.min(l,r));
    }
}