#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b);
long long int lcm(long long int a, long long int b);
long long int modularExponentiation(long long int x, long long int n,
                                    long long int M);
void dsp(vector<long long int> &V);
void dsp2(vector<pair<long long int, long long int>> &V);
void dsp3(map<long long int, long long int> &M);
double fact(double n);
long long int nPr(long long int n, long long int r);
long long int nCr(long long int n, long long int r);
long long int POD(long long int n) {
  long long int cnt = 0;
  long long int pd = 1;
  while (n) {
    cnt = (n % 10);
    pd *= cnt;
    n /= 10;
  }
  return pd;
}
void solve() {
  long long int n, sod, mx, div = 10;
  cin >> n;
  sod = 0;
  mx = -1;
  while (n > 0) {
    sod = POD(n);
    mx = max(mx, sod);
    n = (n / div) * div;
    n--;
    div = div * 10;
  }
  cout << mx << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int modularExponentiation(long long int x, long long int n,
                                    long long int M) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
void dsp(vector<long long int> &V) {
  unsigned long long int j;
  for (j = 0; j < V.size(); j++) {
    cout << V[j] << " ";
  }
  cout << endl;
}
void dsp2(vector<pair<long long int, long long int>> &V) {
  unsigned long long int j;
  for (j = 0; j < V.size(); j++) {
    cout << V[j].first << " " << V[j].second << " ";
  }
  cout << endl;
}
void dsp3(map<long long int, long long int> &M) {
  map<long long int, long long int>::iterator it = M.begin();
  while (it != M.end()) {
    cout << it->first << " " << it->second << endl;
    it++;
  }
}
double fact(double n) {
  double i = 1;
  double res = 1;
  if (n == 0) return 1.00;
  while (i <= n) {
    res *= i;
    i++;
  }
  return res;
}
long long int nPr(long long int n, long long int r) {
  return (fact(n) / fact(n - r));
}
long long int nCr(long long int n, long long int r) {
  return (fact(n) / (fact(r) * fact(n - r)));
}

### 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;
long long int gcd(long long int a, long long int b);
long long int lcm(long long int a, long long int b);
long long int modularExponentiation(long long int x, long long int n,
                                    long long int M);
void dsp(vector<long long int> &V);
void dsp2(vector<pair<long long int, long long int>> &V);
void dsp3(map<long long int, long long int> &M);
double fact(double n);
long long int nPr(long long int n, long long int r);
long long int nCr(long long int n, long long int r);
long long int POD(long long int n) {
  long long int cnt = 0;
  long long int pd = 1;
  while (n) {
    cnt = (n % 10);
    pd *= cnt;
    n /= 10;
  }
  return pd;
}
void solve() {
  long long int n, sod, mx, div = 10;
  cin >> n;
  sod = 0;
  mx = -1;
  while (n > 0) {
    sod = POD(n);
    mx = max(mx, sod);
    n = (n / div) * div;
    n--;
    div = div * 10;
  }
  cout << mx << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int modularExponentiation(long long int x, long long int n,
                                    long long int M) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
void dsp(vector<long long int> &V) {
  unsigned long long int j;
  for (j = 0; j < V.size(); j++) {
    cout << V[j] << " ";
  }
  cout << endl;
}
void dsp2(vector<pair<long long int, long long int>> &V) {
  unsigned long long int j;
  for (j = 0; j < V.size(); j++) {
    cout << V[j].first << " " << V[j].second << " ";
  }
  cout << endl;
}
void dsp3(map<long long int, long long int> &M) {
  map<long long int, long long int>::iterator it = M.begin();
  while (it != M.end()) {
    cout << it->first << " " << it->second << endl;
    it++;
  }
}
double fact(double n) {
  double i = 1;
  double res = 1;
  if (n == 0) return 1.00;
  while (i <= n) {
    res *= i;
    i++;
  }
  return res;
}
long long int nPr(long long int n, long long int r) {
  return (fact(n) / fact(n - r));
}
long long int nCr(long long int n, long long int r) {
  return (fact(n) / (fact(r) * fact(n - r)));
}

```