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 Main {

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

        char[] s = scanner.next().toCharArray();
        long ans = 0;
        for (int len = 1; len < s.length; len++) {
            long cur = 1;
            for (int i = 0; i < len; i++) {
                cur *= 9;
            }
            ans = Math.max(ans, cur);
        }
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '0') {
                continue;
            }
            long cur = s[i] - '0' - 1;
            for (int j = 0; j < i; j++) {
                cur *= s[j] - '0';
            }
            for (int j = i + 1; j < s.length; j++) {
                cur *= 9;
            }
            ans = Math.max(ans, cur);
        }

        long p = 1;
        for (int i = 0; i < s.length; i++) {
            p *= s[i] - '0';
        }
        ans = Math.max(ans, p);

        writer.println(ans);

        writer.close();
    }

    final static class FastScanner implements AutoCloseable {
        private final int BUFFER_CAPACITY = 1024;

        private final InputStream stream;
        private final byte[] buffer = new byte[BUFFER_CAPACITY];
        private int size = 0;
        private int current = 0;
        private char lastReadedChar = '\0';

        FastScanner(InputStream stream) {
            this.stream = stream;
        }

        FastScanner(String filename) throws IOException {
            this.stream = new FileInputStream(filename);
        }

        public void close() throws Exception {
            stream.close();
        }

        boolean hasNextLine() throws Exception {
            try {
                return Character.isWhitespace(lastReadedChar) || !endOfInputReached();
            } catch (IOException e) {
                return false;
            }
        }


        char nextChar() throws Exception {
            byte firstByte = nextByte();
            int octets = 0;
            for (int i = 7; (firstByte >> i & 1) == 1; i--) {
                octets++;
            }
            if (octets == 0) {
                return (char) firstByte;
            }
            char res = 0;
            for (int bit = 7 - octets; bit >= 0; bit--) {
                res <<= 1;
                res += (firstByte >> bit) & 1;
            }
            for (int i = 1; i < octets; i++) {
                res <<= 6;
                res += nextByte() + 128;
            }
            return res;
        }

        String next() throws Exception {
            do {
                lastReadedChar = nextChar();
            } while (Character.isWhitespace(lastReadedChar));
            StringBuilder res = new StringBuilder();
            while (!endOfInputReached() && !Character.isWhitespace(lastReadedChar)) {
                res.append(lastReadedChar);
                lastReadedChar = nextChar();
            }
            if (!Character.isWhitespace(lastReadedChar)) {
                res.append(lastReadedChar);
            }
            return res.toString();
        }

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

        private byte nextByte() throws Exception {
            if (endOfInputReached()) {
                throw new Exception();
            }
            return buffer[current++];
        }

        private void fillBuffer() throws Exception {
            do {
                size = stream.read(buffer);
            } while (size == 0);
            current = 0;
        }

        private boolean endOfInputReached() throws Exception {
            if (current >= size) {
                fillBuffer();
            }
            return size == -1;
        }
    }
}