#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int M = 1005;
const long long mod = 1000000007;
const int inf = (1 << 30);
const long long linf = (1LL << 61);
long long u, n, nr, mx, px;
long long desc(long long x) {
  long long p = 1LL;
  while (x) {
    p *= x % 10;
    x /= 10;
  }
  return p;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cin >> n;
  u = 1LL;
  while (u <= n) u *= 10;
  u /= 10;
  while (u) {
    px = n / u;
    if (px % 10 == 0) {
      px = n % u;
      n -= px - 1;
      px = n / u;
    }
    px *= u;
    nr = px - 1;
    mx = max(mx, desc(nr));
    u /= 10;
  }
  mx = max(mx, desc(n));
  cout << mx;
  return 0;
}
