#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n;
long long calc(int x) {
  if (x < 10) return max(x, 1);
  return max(1ll * (x % 10) * calc(x / 10), 1ll * 9 * calc(x / 10 - 1));
}
void solve() {
  scanf("%d", &n);
  printf("%lld", calc(n));
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
