#include <bits/stdc++.h>
using namespace std;
long long func(long long n) {
  long long ans = 1;
  while (n) {
    ans *= n % 10;
    n /= 10;
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long ans = 0;
  long long t = 1;
  while (t < 1000000000000000000) {
    t *= 10;
    ans = max(ans, func(n));
    n = n - n % t - 1;
  }
  cout << ans;
}
