#include <bits/stdc++.h>
using namespace std;
vector<long long> ara;
long long func(long long idx, bool small) {
  if (idx == ara.size()) return 1;
  long long ret = 0;
  if (small) {
    ret = 9 * func(idx + 1, small);
  } else {
    ret = 0;
    for (long long i = 1; i < ara[idx]; i++) {
      ret = max(ret, i * func(idx + 1, true));
    }
    ret = max(ret, ara[idx] * func(idx + 1, small));
  }
  return ret;
}
int main() {
  long long n;
  cin >> n;
  while (n) {
    long long rem = n % 10;
    ara.push_back(rem);
    n /= 10;
  }
  reverse(ara.begin(), ara.end());
  long long ans = func(0, false);
  ans = max(ans, func(1, true));
  cout << ans << endl;
  return 0;
}
