#include <bits/stdc++.h>
using namespace std;
int main() {
  long long ans = 1, a[10], val;
  int i = 0, j = 0;
  cin >> val;
  while (val > 0) {
    a[i] = val % 10;
    val /= 10;
    ans *= a[i];
    i++;
  }
  int n = i;
  for (i = 0; i < n - 1; i++) {
    a[i] = 9;
    if (a[i + 1] > 1) a[i + 1]--;
    long long Ans = 1;
    for (j = 0; j < n; j++) {
      Ans *= a[j];
    }
    ans = max(ans, Ans);
  }
  cout << ans;
}
