#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  scanf("%d", &n);
  int mx = 1;
  for (int x = n; x; x /= 10) mx *= x % 10;
  for (int i = 1; i <= 9; ++i) {
    int x = n;
    for (int j = 1; j <= i; ++j) x /= 10;
    for (int j = 1; j <= i; ++j) x *= 10;
    if (!x) break;
    --x;
    int calc = 1;
    for (; x; x /= 10) calc *= x % 10;
    if (calc > mx) mx = calc;
  }
  printf("%d", mx);
}
