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.io.*;
public class nirvana
{
    static class InputReader {
        private InputStream stream;
        private byte[] inbuf = new byte[1024];
        private int start= 0;
        private int end = 0;

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

        private int readByte() {
            if (start == -1) throw new UnknownError();
            if (end >= start) {
                end= 0;
                try {
                    start= stream.read(inbuf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (start<= 0) return -1;
            }
            return inbuf[end++];
        }

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

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

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

        public int nextInt() {
            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();
            }
        }

        public long nextLong() {
            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();
            }
        }
    }
    static long count(String s)
    {
        int pro=1;
        for(int i=0;i<s.length();i++)
        {
            pro=pro*(Character.getNumericValue(s.charAt(i)));
        }
        return pro;
    }
    public static void main(String args[])
    {
        InputReader sc=new InputReader(System.in);
        String s=sc.next();
        StringBuilder w;
        long ans=count(s);
        long c=1;
        if(s.charAt(0)=='1')
        {
            for(int i=1;i<s.length();i++)
                c=c*9;
            System.out.println(c);
        }
        else
        {
            for(int i=0;i<s.length();i++)
            {
                if(s.charAt(i)!=0)
                {
                    w=new StringBuilder(s);
                    w.setCharAt(i,(char)(w.charAt(i)-1));
                    for(int j=i+1;j<s.length();j++)
                    {
                        w.setCharAt(j,'9');
                    }
                    //System.out.println(w);
                    c=count(w.toString());
                    ans=Math.max(ans,c);
                }
            }
            System.out.println(ans);
        }
    }
}
