#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 200;
const int inf = 0x3f3f3f3f;
const double eps = 1e-7;
const double pi = acos(-1.0);
const int mod = 1e9 + 7;
inline int lowbit(int x) { return x & (-x); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void ex_gcd(long long a, long long b, long long &d, long long &x,
            long long &y) {
  if (!b) {
    d = a, x = 1, y = 0;
  } else {
    ex_gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
inline long long qpow(long long a, long long b, long long MOD = mod) {
  long long res = 1;
  a %= MOD;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
inline long long inv(long long x, long long p) { return qpow(x, p - 2, p); }
inline long long Jos(long long n, long long k, long long s = 1) {
  long long res = 0;
  for (int i = 1; i <= n + 1; ++i) res = (res + k) % i;
  return (res + s) % n;
}
inline long long read() {
  long long f = 1;
  long long x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * f;
}
int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
long long dp[20][2][2];
string s;
long long dfs(int pos, int limit, int zero) {
  if (pos >= s.size()) return 1;
  if (dp[pos][limit][zero] != -1) return dp[pos][limit][zero];
  long long up = (limit) ? (s[pos] - '0') : 9;
  long long ma = 0;
  for (int i = 0; i <= up; ++i) {
    ma = (((i == 0 ? 1 : i) *
           dfs(pos + 1, i == (s[pos] - '0') && limit, i == 0 && zero)) > (ma)
              ? ((i == 0 ? 1 : i) *
                 dfs(pos + 1, i == (s[pos] - '0') && limit, i == 0 && zero))
              : (ma));
  }
  if (!limit && !zero) dp[pos][limit][zero] = ma;
  return ma;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> s;
  cout << dfs(0, 1, 1) << '\n';
  return 0;
}

### Prompt

Generate a CPP solution to the following problem:

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).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 200;
const int inf = 0x3f3f3f3f;
const double eps = 1e-7;
const double pi = acos(-1.0);
const int mod = 1e9 + 7;
inline int lowbit(int x) { return x & (-x); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void ex_gcd(long long a, long long b, long long &d, long long &x,
            long long &y) {
  if (!b) {
    d = a, x = 1, y = 0;
  } else {
    ex_gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
inline long long qpow(long long a, long long b, long long MOD = mod) {
  long long res = 1;
  a %= MOD;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
inline long long inv(long long x, long long p) { return qpow(x, p - 2, p); }
inline long long Jos(long long n, long long k, long long s = 1) {
  long long res = 0;
  for (int i = 1; i <= n + 1; ++i) res = (res + k) % i;
  return (res + s) % n;
}
inline long long read() {
  long long f = 1;
  long long x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * f;
}
int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
long long dp[20][2][2];
string s;
long long dfs(int pos, int limit, int zero) {
  if (pos >= s.size()) return 1;
  if (dp[pos][limit][zero] != -1) return dp[pos][limit][zero];
  long long up = (limit) ? (s[pos] - '0') : 9;
  long long ma = 0;
  for (int i = 0; i <= up; ++i) {
    ma = (((i == 0 ? 1 : i) *
           dfs(pos + 1, i == (s[pos] - '0') && limit, i == 0 && zero)) > (ma)
              ? ((i == 0 ? 1 : i) *
                 dfs(pos + 1, i == (s[pos] - '0') && limit, i == 0 && zero))
              : (ma));
  }
  if (!limit && !zero) dp[pos][limit][zero] = ma;
  return ma;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> s;
  cout << dfs(0, 1, 1) << '\n';
  return 0;
}

```