#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 10;
inline long long add(long long x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline long long mul(long long x, long long y) {
  x = (1LL * x * y) % mod;
  return x;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  long long l = s.length();
  long long ans = 1;
  for (long long i = 0; i < l; i++) ans *= (s[i] - '0');
  for (long long i = 0; i < l; i++) {
    long long val = 1;
    if (i == 0) {
      val = val * (s[0] - '1' == 0 ? 1 : s[0] - '1');
    } else {
      for (long long j = 0; j < i; j++) {
        val = val * (s[j] - '0');
      }
      val = val * (s[i] - '0' - 1);
    }
    for (long long j = i + 1; j < l; j++) val *= 9;
    ans = max(ans, val);
  }
  cout << ans;
  return 0;
}
