#include <bits/stdc++.h>
using namespace std;
long long int sum(int k) {
  long long int prod = 1;
  while (k) {
    prod *= k % 10;
    k /= 10;
  }
  return prod;
}
int main() {
  long long int n, high = -1, temp, c = 0, a = 0, prod;
  scanf("%lld", &n);
  string str = to_string(n);
  temp = n;
  while (temp) {
    temp = temp / 10;
    c++;
  }
  int l = c;
  while (c--) {
    int k = stoi(str);
    prod = sum(k);
    str[l - 1 - a] = '9';
    if (str[l - a - 2] > 1) str[l - a - 2] -= 1;
    a++;
    high = max(high, prod);
  }
  printf("%lld", high);
  return 0;
}
