#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  string s = to_string(n);
  long long P[20] = {0};
  P[0] = 1;
  for (long long i = 1; i <= 19; i++) {
    P[i] = P[i - 1] * 9;
  }
  long long sz = s.size();
  long long cans = 1;
  for (long long i = 0; i < sz; i++) {
    long long lim = s[i] - '0';
    for (long long j = 0; j < lim; j++) {
      long long xx = cans * j * (P[sz - 1 - i]);
      ans = max(ans, xx);
    }
    cans = cans * lim;
    if (i != (sz - 1)) {
      ans = max(ans, P[i + 1]);
    }
  }
  ans = max(ans, cans);
  cout << ans << endl;
  return 0;
}
