#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ct = 0;
  cin >> n;
  int a[11], i = 0;
  while (n != 0) {
    a[i] = n % 10;
    n = n / 10;
    ct++;
    i++;
  }
  int ans = INT_MIN;
  int pro = 1;
  for (int i = 0; i < ct; i++) {
    pro = pro * a[i];
  }
  ans = max(ans, pro);
  if (a[ct - 1] == 1) {
    int k = pow(9, ct - 1);
    ans = max(ans, k);
  } else {
    int k = pow(9, ct - 1);
    ans = max(ans, k * (a[ct - 1] - 1));
  }
  for (int i = ct - 2; i >= 0; i--) {
    pro = 1;
    for (int j = ct - 1; j > i; j--) {
      pro = pro * a[j];
    }
    pro = pro * (a[i] - 1) * pow(9, i);
    ans = max(ans, pro);
  }
  cout << ans << endl;
}
