Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.

Help Kurt find the maximum possible product of digits among all integers from 1 to n.

Input

The only input line contains the integer n (1 ≤ n ≤ 2⋅10^9).

Output

Print the maximum product of digits among all integers from 1 to n.

Examples

Input


390


Output


216


Input


7


Output


7


Input


1000000000


Output


387420489

Note

In the first example the maximum product is achieved for 389 (the product of digits is 3⋅8⋅9=216).

In the second example the maximum product is achieved for 7 (the product of digits is 7).

In the third example the maximum product is achieved for 999999999 (the product of digits is 9^9=387420489).
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class Task {

    public static void solve() throws Exception {
	int n = nextInt();
	int ret = 0;
	if(n >= 1) { ret = 1; }
	if(n >= 2) { ret = 2; }
	if(n >= 3) { ret = 3; }
	if(n >= 4) { ret = 4; }
	if(n >= 5) { ret = 5; }
	if(n >= 6) { ret = 6; }
	if(n >= 7) { ret = 7; }
	if(n >= 8) { ret = 8; }
	if(n >= 9) { ret = 9; }
	if(n >= 25) { ret = 10; }
	if(n >= 26) { ret = 12; }
	if(n >= 27) { ret = 14; }
	if(n >= 28) { ret = 16; }
	if(n >= 29) { ret = 18; }
	if(n >= 37) { ret = 21; }
	if(n >= 38) { ret = 24; }
	if(n >= 39) { ret = 27; }
	if(n >= 47) { ret = 28; }
	if(n >= 48) { ret = 32; }
	if(n >= 49) { ret = 36; }
	if(n >= 58) { ret = 40; }
	if(n >= 59) { ret = 45; }
	if(n >= 68) { ret = 48; }
	if(n >= 69) { ret = 54; }
	if(n >= 78) { ret = 56; }
	if(n >= 79) { ret = 63; }
	if(n >= 88) { ret = 64; }
	if(n >= 89) { ret = 72; }
	if(n >= 99) { ret = 81; }
	if(n >= 259) { ret = 90; }
	if(n >= 268) { ret = 96; }
	if(n >= 269) { ret = 108; }
	if(n >= 278) { ret = 112; }
	if(n >= 279) { ret = 126; }
	if(n >= 288) { ret = 128; }
	if(n >= 289) { ret = 144; }
	if(n >= 299) { ret = 162; }
	if(n >= 378) { ret = 168; }
	if(n >= 379) { ret = 189; }
	if(n >= 388) { ret = 192; }
	if(n >= 389) { ret = 216; }
	if(n >= 399) { ret = 243; }
	if(n >= 479) { ret = 252; }
	if(n >= 488) { ret = 256; }
	if(n >= 489) { ret = 288; }
	if(n >= 499) { ret = 324; }
	if(n >= 589) { ret = 360; }
	if(n >= 599) { ret = 405; }
	if(n >= 689) { ret = 432; }
	if(n >= 699) { ret = 486; }
	if(n >= 789) { ret = 504; }
	if(n >= 799) { ret = 567; }
	if(n >= 889) { ret = 576; }
	if(n >= 899) { ret = 648; }
	if(n >= 999) { ret = 729; }
	if(n >= 2599) { ret = 810; }
	if(n >= 2689) { ret = 864; }
	if(n >= 2699) { ret = 972; }
	if(n >= 2789) { ret = 1008; }
	if(n >= 2799) { ret = 1134; }
	if(n >= 2889) { ret = 1152; }
	if(n >= 2899) { ret = 1296; }
	if(n >= 2999) { ret = 1458; }
	if(n >= 3789) { ret = 1512; }
	if(n >= 3799) { ret = 1701; }
	if(n >= 3889) { ret = 1728; }
	if(n >= 3899) { ret = 1944; }
	if(n >= 3999) { ret = 2187; }
	if(n >= 4799) { ret = 2268; }
	if(n >= 4889) { ret = 2304; }
	if(n >= 4899) { ret = 2592; }
	if(n >= 4999) { ret = 2916; }
	if(n >= 5899) { ret = 3240; }
	if(n >= 5999) { ret = 3645; }
	if(n >= 6899) { ret = 3888; }
	if(n >= 6999) { ret = 4374; }
	if(n >= 7899) { ret = 4536; }
	if(n >= 7999) { ret = 5103; }
	if(n >= 8899) { ret = 5184; }
	if(n >= 8999) { ret = 5832; }
	if(n >= 9999) { ret = 6561; }
	if(n >= 25999) { ret = 7290; }
	if(n >= 26899) { ret = 7776; }
	if(n >= 26999) { ret = 8748; }
	if(n >= 27899) { ret = 9072; }
	if(n >= 27999) { ret = 10206; }
	if(n >= 28899) { ret = 10368; }
	if(n >= 28999) { ret = 11664; }
	if(n >= 29999) { ret = 13122; }
	if(n >= 37899) { ret = 13608; }
	if(n >= 37999) { ret = 15309; }
	if(n >= 38899) { ret = 15552; }
	if(n >= 38999) { ret = 17496; }
	if(n >= 39999) { ret = 19683; }
	if(n >= 47999) { ret = 20412; }
	if(n >= 48899) { ret = 20736; }
	if(n >= 48999) { ret = 23328; }
	if(n >= 49999) { ret = 26244; }
	if(n >= 58999) { ret = 29160; }
	if(n >= 59999) { ret = 32805; }
	if(n >= 68999) { ret = 34992; }
	if(n >= 69999) { ret = 39366; }
	if(n >= 78999) { ret = 40824; }
	if(n >= 79999) { ret = 45927; }
	if(n >= 88999) { ret = 46656; }
	if(n >= 89999) { ret = 52488; }
	if(n >= 99999) { ret = 59049; }
	if(n >= 259999) { ret = 65610; }
	if(n >= 268999) { ret = 69984; }
	if(n >= 269999) { ret = 78732; }
	if(n >= 278999) { ret = 81648; }
	if(n >= 279999) { ret = 91854; }
	if(n >= 288999) { ret = 93312; }
	if(n >= 289999) { ret = 104976; }
	if(n >= 299999) { ret = 118098; }
	if(n >= 378999) { ret = 122472; }
	if(n >= 379999) { ret = 137781; }
	if(n >= 388999) { ret = 139968; }
	if(n >= 389999) { ret = 157464; }
	if(n >= 399999) { ret = 177147; }
	if(n >= 479999) { ret = 183708; }
	if(n >= 488999) { ret = 186624; }
	if(n >= 489999) { ret = 209952; }
	if(n >= 499999) { ret = 236196; }
	if(n >= 589999) { ret = 262440; }
	if(n >= 599999) { ret = 295245; }
	if(n >= 689999) { ret = 314928; }
	if(n >= 699999) { ret = 354294; }
	if(n >= 789999) { ret = 367416; }
	if(n >= 799999) { ret = 413343; }
	if(n >= 889999) { ret = 419904; }
	if(n >= 899999) { ret = 472392; }
	if(n >= 999999) { ret = 531441; }
	if(n >= 2599999) { ret = 590490; }
	if(n >= 2689999) { ret = 629856; }
	if(n >= 2699999) { ret = 708588; }
	if(n >= 2789999) { ret = 734832; }
	if(n >= 2799999) { ret = 826686; }
	if(n >= 2889999) { ret = 839808; }
	if(n >= 2899999) { ret = 944784; }
	if(n >= 2999999) { ret = 1062882; }
	if(n >= 3789999) { ret = 1102248; }
	if(n >= 3799999) { ret = 1240029; }
	if(n >= 3889999) { ret = 1259712; }
	if(n >= 3899999) { ret = 1417176; }
	if(n >= 3999999) { ret = 1594323; }
	if(n >= 4799999) { ret = 1653372; }
	if(n >= 4889999) { ret = 1679616; }
	if(n >= 4899999) { ret = 1889568; }
	if(n >= 4999999) { ret = 2125764; }
	if(n >= 5899999) { ret = 2361960; }
	if(n >= 5999999) { ret = 2657205; }
	if(n >= 6899999) { ret = 2834352; }
	if(n >= 6999999) { ret = 3188646; }
	if(n >= 7899999) { ret = 3306744; }
	if(n >= 7999999) { ret = 3720087; }
	if(n >= 8899999) { ret = 3779136; }
	if(n >= 8999999) { ret = 4251528; }
	if(n >= 9999999) { ret = 4782969; }
	if(n >= 25999999) { ret = 5314410; }
	if(n >= 26899999) { ret = 5668704; }
	if(n >= 26999999) { ret = 6377292; }
	if(n >= 27899999) { ret = 6613488; }
	if(n >= 27999999) { ret = 7440174; }
	if(n >= 28899999) { ret = 7558272; }
	if(n >= 28999999) { ret = 8503056; }
	if(n >= 29999999) { ret = 9565938; }
	if(n >= 37899999) { ret = 9920232; }
	if(n >= 37999999) { ret = 11160261; }
	if(n >= 38899999) { ret = 11337408; }
	if(n >= 38999999) { ret = 12754584; }
	if(n >= 39999999) { ret = 14348907; }
	if(n >= 47999999) { ret = 14880348; }
	if(n >= 48899999) { ret = 15116544; }
	if(n >= 48999999) { ret = 17006112; }
	if(n >= 49999999) { ret = 19131876; }
	if(n >= 58999999) { ret = 21257640; }
	if(n >= 59999999) { ret = 23914845; }
	if(n >= 68999999) { ret = 25509168; }
	if(n >= 69999999) { ret = 28697814; }
	if(n >= 78999999) { ret = 29760696; }
	if(n >= 79999999) { ret = 33480783; }
	if(n >= 88999999) { ret = 34012224; }
	if(n >= 89999999) { ret = 38263752; }
	if(n >= 99999999) { ret = 43046721; }
	if(n >= 259999999) { ret = 47829690; }
	if(n >= 268999999) { ret = 51018336; }
	if(n >= 269999999) { ret = 57395628; }
	if(n >= 278999999) { ret = 59521392; }
	if(n >= 279999999) { ret = 66961566; }
	if(n >= 288999999) { ret = 68024448; }
	if(n >= 289999999) { ret = 76527504; }
	if(n >= 299999999) { ret = 86093442; }
	if(n >= 378999999) { ret = 89282088; }
	if(n >= 379999999) { ret = 100442349; }
	if(n >= 388999999) { ret = 102036672; }
	if(n >= 389999999) { ret = 114791256; }
	if(n >= 399999999) { ret = 129140163; }
	if(n >= 479999999) { ret = 133923132; }
	if(n >= 488999999) { ret = 136048896; }
	if(n >= 489999999) { ret = 153055008; }
	if(n >= 499999999) { ret = 172186884; }
	if(n >= 589999999) { ret = 191318760; }
	if(n >= 599999999) { ret = 215233605; }
	if(n >= 689999999) { ret = 229582512; }
	if(n >= 699999999) { ret = 258280326; }
	if(n >= 789999999) { ret = 267846264; }
	if(n >= 799999999) { ret = 301327047; }
	if(n >= 889999999) { ret = 306110016; }
	if(n >= 899999999) { ret = 344373768; }
	if(n >= 999999999) { ret = 387420489; }
	println(ret);	

	
	/*int max = 0;
	for(int i=1;i<=999999999;i++) {
	    int prod = prod(i);
	    if(prod > max) {
		max = prod;
		println("if(n >= " + i + ") { ret = " + prod + "; }");
	    }
	}
	println(max);*/
    }

    private static int prod(int j) {
	int prod = 1;
	while (true) {
	    int r = j % 10;
	    prod *= r;
	    j /= 10;
	    if (j == 0) {
		break;
	    }
	}
	return prod;
    }

    public static void main(String[] args) throws Exception {
	try {
	    fastReader = new FastReader(System.in);
	    systemOut = new BufferedOutputStream(System.out);
	    solve();
	} finally {
	    systemOut.close();
	}
    }

    private static FastReader fastReader = null;
    private static BufferedOutputStream systemOut = null;

    public static void print(Object obj) {
	print(obj.toString());
    }

    public static void print(String str) {
	try {
	    systemOut.write(str.getBytes("utf-8"));
	} catch (Exception ex) {
	    throw new RuntimeException(ex);
	}
    }

    public static void println(Object obj) {
	println(obj.toString());
    }

    public static void println(String str) {
	try {
	    print(str);
	    systemOut.write('\n');
	} catch (Exception ex) {
	    throw new RuntimeException(ex);
	}
    }

    public static String next() {
	return fastReader.readNextToken(false);
    }

    public static String nextLine() {
	return fastReader.readNextToken(true);
    }

    public static int nextInt() {
	return Integer.parseInt(fastReader.readNextToken(false));
    }

    public static long nextLong() {
	return Long.parseLong(fastReader.readNextToken(false));
    }

    public static double nextDouble() {
	return Double.parseDouble(fastReader.readNextToken(false));
    }

    public static void exit() {
	try {
	    systemOut.close();
	} catch (IOException e) {
	    // should never happen
	}
	System.exit(0);
    }

    static class FastReader {
	private byte[] buf = new byte[65536];
	private int ind = 0;
	private int maxInd = -1;
	private InputStream is = null;
	private boolean eof = false;
	private boolean lastCharRead = false;

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

	public String readNextToken(boolean endOfLine) {
	    try {
		StringBuilder sb = new StringBuilder();
		boolean found = false;
		while (true) {
		    if (lastCharRead) {
			return null;
		    } else if (ind > maxInd) {
			if (eof) {
			    lastCharRead = true;
			} else {
			    fillBuffer();
			}
		    }
		    byte b = '\n';
		    if (!lastCharRead) {
			b = buf[ind++];
		    }

		    if (b == '\r') {
			// ignore
		    } else if ((b == '\n' && endOfLine) || (Character.isWhitespace(b) && !endOfLine)) {
			if (found) {
			    break;
			}
		    } else {
			sb.append((char) b);
			found = true;
		    }
		}
		return sb.toString();
	    } catch (Exception ex) {
		throw new RuntimeException(ex);
	    }
	}

	private void fillBuffer() {
	    try {
		int read = is.read(buf, 0, buf.length);
		if (read < buf.length) {
		    eof = true;
		}
		ind = 0;
		maxInd = read - 1;
	    } catch (Exception ex) {
		throw new RuntimeException(ex);
	    }
	}
    }
}
