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.util.*;
		import java.util.*;
		import javax.swing.plaf.synth.SynthSpinnerUI;
		import javax.swing.plaf.synth.SynthStyle;
		import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
		import java.util.StringTokenizer;
		import java.io.BufferedReader;
		import java.io.IOException;
		import java.io.InputStreamReader;
		
		public class mohamedy23
				{
			//to order according region and score
		public static	class Pair implements Comparable<Pair> {
		  		int reg, score;String s;
		   
		  		public Pair(int reg, int score,String s) {
		  			this.reg = reg;
		  			this.score = score;
		  			this.s=s;
		  		}
		   
		  		public int compareTo(Pair A) {
		  			if(reg==A.reg)return A.score-score;
		  			return reg-A.reg;
		  		}
		  		public String toString() {
		  			return reg+" "+score+" "+s;
		  		}
		   
		  		
		  	}
		public static boolean jk(String s) {
			boolean f=true;
			for(int i=0;i<s.length();i++) {
				if(s.charAt(i)=='0') {
					f=false;break;
				}else f=true;
			}
			return f;
		}
		//product of digits
		public static long product(int n) {
			int k=1;
			for( ;n>0;n=n/10) {
				k=k*(n%10);
			}
			return k;
		}public static long product2(int o) {
			int k=1;
			for( ;o>0;o=o/10) {
				k=k*(o%10);
			}
			return k;
		}
		
		public static int lol(String s) {long f=1;
			
		    	for(int j=0;j<s.indexOf('0')-1;j++) {
		    		int k=s.charAt(j);f*=(k-48);//System.out.println(f);
		    	}
		    	if(s.charAt(s.indexOf('0')-1)=='1') {
		    		int y=(int) (Math.pow(9,s.length()-s.indexOf('0')+1));int u=(int) (f*y);
		    		return u;
		    	}else {
		    		int y=(int) (Math.pow(9,s.length()-s.indexOf('0')));//System.out.println(y);
		    		int o=s.charAt(s.indexOf('0')-1);int l=o-48-1;
		    		f=f*y;//System.out.println(f);
		    		f=f*l;
		    	return (int) f;}
		}
		public static int lol2(String d) {long f=1;
		
    	for(int j=0;j<d.indexOf('0')-1;j++) {
    		int k=d.charAt(j);f*=(k-48);//System.out.println(f);
    	}
    	if(d.charAt(d.indexOf('0')-1)=='1') {
    		int y=(int) (Math.pow(9,d.length()-d.indexOf('0')));int u=(int) (f*y);
    		return u;
    	}else {
    		int y=(int) (Math.pow(9,d.length()-d.indexOf('0')));//System.out.println(y);
    		int o=d.charAt(d.indexOf('0')-1);int l=o-48-1;
    		f=f*y;//System.out.println(f);
    		f=f*l;
    	return (int) f;}
}
	
		
		public static int digits(int n) {
			int u=0;
			while(n!=0) {
				u++;n=n/10;
			}
			return u;
		}
		
		public static void main (String args[])throws NumberFormatException, IOException, InterruptedException
				    {
				    	Scanner sc=new Scanner(System.in);
				    	int n=sc.nextInt();int o=n-1;int d;
				    	int r=(int) Math.max(product(n),product(o));int y=(int) Math.pow(10,digits(n)-1);
				    	int y2=(int) Math.pow(10,digits(n)-2);int y3=(int) Math.pow(10,digits(n)-3);
				    	if(digits(n)==1) {
				    		System.out.println(n);
				    	}else if(digits(n)==2) {
				    		if(n/y==1) {
				    			System.out.println(Math.max(r,9));
				    		}else {
				    			System.out.println(Math.max(r,9*((n/y)-1)));
				    		}
				    	}
				    	else {
				    		if(n/y==1) {
				    			d=(int) Math.pow(9,digits(n)-1);
				    			}else {
				    			int h1=n/y;
				    			int h=(n/y2)%10;int h2=(n/y3)%10;//System.out.println(h1+" "+h+" "+h2);
				    			int f=Math.max(h1*(h-1)*9,(h1-1)*9*9);int e=h1*h*(h2-1);
				    			int f2=Math.max(f,e);
				    		    d=(int) (f2*Math.pow(9,digits(n)-3));
				    		}
				    		System.out.println(Math.max(r,d));
				    	}
				    	/*if(!jk(s)) {
				    		System.out.print(lol(s));
				    	}else {
				    		;System.out.println(d);
				    		
				    		
				    		System.out.print(Math.max(product(n),lol2(d)));
				    	}
				    	*/
				    	
				       
				    	
				    	
				    	
				    }

				    
				    	
//				    	System.out.println(Arrays.toString(a));
//				    	System.out.println(Arrays.toString(b));
				    	
				    
			      static int binarySearch(int a[],int x) {
			    	  int l=0;int h=a.length-1;int mid =(l+h)/2;
			    	  
			    		l=0;h=a.length-1;  mid=(l+h)/2;
			    		  for( ;l<=h;) {mid=(l+h)/2;
			    		  if(x==a[mid])return mid;
			    		  else if(x>a[mid])l=mid+1;
			    		  else  h=mid-1;
			    	  
			    	  }
			    	  return -1;
			      }
			      
			   
			      
			      
			      
			      




				//	Bubble Sort    
			      static void bubbleSort(int a[]) 
			      { 
			          int n = a.length; 
			          for (int i = 0; i < n-1; i++) 
			              for (int j = 0; j < n-i-1; j++) 
			                  if (a[j] > a[j+1]) 
			                  { 
			                      // swap arr[j+1] and arr[i] 
			                      int temp = a[j]; 
			                      a[j] = a[j+1]; 
			                      a[j+1] = temp; 
			                  } 
			      }      
			    //Merge Sort
			      
			      	public static void mergeSort(int[] a, int n) {
			      	    if (n < 2) {
			      	        return;
			      	    }
			      	    int mid = n / 2;
			      	    int[] l = new int[mid];
			      	    int[] r = new int[n - mid];
			      	 
			      	    for (int i = 0; i < mid; i++) {
			      	        l[i] = a[i];
			      	    }
			      	    for (int i = mid; i < n; i++) {
			      	        r[i - mid] = a[i];
			      	    }
			      	    mergeSort(l, mid);
			      	    mergeSort(r, n - mid);
			      	 
			      	    merge(a, l, r, mid, n - mid);
			      	}
			      	
			      	public static void merge(
			      			  int[] a, int[] l, int[] r, int left, int right) {
			      			  
			      			    int i = 0, j = 0, k = 0;
			      			    while (i < left && j < right) {
			      			        if (l[i] <= r[j]) {
			      			            a[k++] = l[i++];
			      			        }
			      			        else {
			      			            a[k++] = r[j++];
			      			        }
			      			    }
			      			    while (i < left) {
			      			        a[k++] = l[i++];
			      			    }
			      			    while (j < right) {
			      			        a[k++] = r[j++];
			      			    }
			      			}
			      //Comparable Class to sort 2d array[n][2] according the first column
			    	
			      
			      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);
				  		}
				  	}
			      }
				 