#include <bits/stdc++.h>
using namespace std;
long int paw(long int a) {
  long int b = 1;
  while (a != 0) {
    b = b * 10;
    a = a - 1;
  }
  return b;
}
long int getsum(long int n) {
  long int sum = 1;
  while (n != 0) {
    sum = sum * (n % 10);
    n = n / 10;
  }
  return sum;
}
int main() {
  long int n, i, count = 0, maxi = 1, flag;
  cin >> n;
  long int k = n;
  while (k != 0) {
    maxi = (maxi) * (k % 10);
    k = k / 10;
    count++;
  }
  for (i = 1; i < count; i++) {
    if (((n % paw(i)) / paw(i - 1)) != 9) {
      n = (n / paw(i) - 1) * paw(i) + paw(i) - 1;
      maxi = max(maxi, getsum(n));
    }
  }
  cout << maxi;
  return 0;
}
