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).
#include <bits/stdc++.h>
int arr[1010] = {
    0,         531441,    531441,    1062882,   1594323,   2125764,
    2657205,   3188646,   3720087,   4251528,   4782969,   4782969,
    4782969,   4782969,   4782969,   4782969,   4782969,   4782969,
    4782969,   4782969,   4782969,   4782969,   4782969,   4782969,
    4782969,   4782969,   5314410,   6377292,   7440174,   8503056,
    9565938,   9565938,   9565938,   9565938,   9565938,   9565938,
    9565938,   9565938,   11160261,  12754584,  14348907,  14348907,
    14348907,  14348907,  14348907,  14348907,  14348907,  14348907,
    14880348,  17006112,  19131876,  19131876,  19131876,  19131876,
    19131876,  19131876,  19131876,  19131876,  19131876,  21257640,
    23914845,  23914845,  23914845,  23914845,  23914845,  23914845,
    23914845,  23914845,  23914845,  25509168,  28697814,  28697814,
    28697814,  28697814,  28697814,  28697814,  28697814,  28697814,
    28697814,  29760696,  33480783,  33480783,  33480783,  33480783,
    33480783,  33480783,  33480783,  33480783,  33480783,  34012224,
    38263752,  38263752,  38263752,  38263752,  38263752,  38263752,
    38263752,  38263752,  38263752,  38263752,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  43046721,  43046721,  43046721,  43046721,
    43046721,  43046721,  47829690,  47829690,  47829690,  47829690,
    47829690,  47829690,  47829690,  47829690,  47829690,  51018336,
    57395628,  57395628,  57395628,  57395628,  57395628,  57395628,
    57395628,  57395628,  57395628,  59521392,  66961566,  66961566,
    66961566,  66961566,  66961566,  66961566,  66961566,  66961566,
    66961566,  68024448,  76527504,  76527504,  76527504,  76527504,
    76527504,  76527504,  76527504,  76527504,  76527504,  76527504,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  86093442,  86093442,  86093442,  86093442,  86093442,
    86093442,  89282088,  100442349, 100442349, 100442349, 100442349,
    100442349, 100442349, 100442349, 100442349, 100442349, 102036672,
    114791256, 114791256, 114791256, 114791256, 114791256, 114791256,
    114791256, 114791256, 114791256, 114791256, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    129140163, 129140163, 129140163, 129140163, 129140163, 129140163,
    133923132, 133923132, 133923132, 133923132, 133923132, 133923132,
    133923132, 133923132, 133923132, 136048896, 153055008, 153055008,
    153055008, 153055008, 153055008, 153055008, 153055008, 153055008,
    153055008, 153055008, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 172186884, 172186884, 172186884, 172186884,
    172186884, 172186884, 191318760, 191318760, 191318760, 191318760,
    191318760, 191318760, 191318760, 191318760, 191318760, 191318760,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    215233605, 215233605, 215233605, 215233605, 215233605, 215233605,
    229582512, 229582512, 229582512, 229582512, 229582512, 229582512,
    229582512, 229582512, 229582512, 229582512, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 258280326, 258280326,
    258280326, 258280326, 258280326, 258280326, 267846264, 267846264,
    267846264, 267846264, 267846264, 267846264, 267846264, 267846264,
    267846264, 267846264, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 301327047, 301327047, 301327047, 301327047,
    301327047, 301327047, 306110016, 306110016, 306110016, 306110016,
    306110016, 306110016, 306110016, 306110016, 306110016, 306110016,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 344373768, 344373768,
    344373768, 344373768, 344373768, 344373768, 387420489};
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  if (n >= 1000000000) {
    printf("387420489\n");
  } else {
    long long tmp = n / 1000000;
    long long anss = arr[tmp];
    for (int i = tmp * 1000000; i <= n; i++) {
      long long sum = 1;
      int tmp = i;
      while (tmp) {
        sum *= tmp % 10;
        if (tmp % 10 == 0) break;
        tmp /= 10;
      }
      anss = max(anss, sum);
    }
    printf("%lld\n", anss);
  }
}
