#include <bits/stdc++.h>
using namespace std;
int num[15];
int tot;
int res = 0;
int main() {
  int n;
  scanf("%d", &n);
  while (n) {
    num[++tot] = n % 10;
    n /= 10;
  }
  int tmp = 1;
  for (int i = tot; i >= 1; i--) {
    tmp *= num[i];
  }
  res = max(res, tmp);
  for (int i = tot; i >= 1; i--) {
    if (num[i] == 0) break;
    tmp = 1;
    for (int j = tot; j >= i + 1; j--) {
      tmp *= num[j];
    }
    tmp *= (num[i] - 1);
    for (int j = i - 1; j >= 1; j--) {
      tmp *= 9;
    }
    res = max(res, tmp);
  }
  res = max(res, (int)pow(9, tot - 1));
  printf("%d\n", res);
}
