#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long t, id, n, m, x, y, k, c, p, dif, ans, sum, pre, rem, cur, tmp, tot, r,
    l, u, d, xx, yy;
int a[N], vis[N], f[N], b[N], cu[N];
bool fl, ok;
vector<long long> v, adj[N];
int main() {
  scanf("%lld", &n);
  m = n;
  ans = 1;
  while (m) {
    ++c;
    ans *= m % 10;
    v.push_back(m % 10);
    m /= 10;
  }
  x = v.size();
  for (int i = 0; i <= (int)x - 1; ++i) {
    if (!v[i]) continue;
    cur = v[i] - 1;
    if (i == x - 1) cur = max(cur, 1LL);
    for (int j = 0; j <= (int)i - 1; ++j) cur *= 9;
    for (int j = i + 1; j <= (int)x - 1; ++j) cur *= v[j];
    ans = max(cur, ans);
  }
  printf("%lld\n", ans);
  return 0;
}
