#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i{0}, j, ctr = 0, m, arr[100], product[100]{1}, rem;
  cin >> i;
  m = i;
  while (m != 0) {
    m = m / 10;
    ctr++;
  }
  long long k = -1;
  arr[0] = i;
  for (int g = 1; g < ctr; g++) {
    long long pro = 1;
    arr[g] = (i / 10) - 1;
    while (arr[g] != 0) {
      rem = arr[g] % 10;
      pro = pro * rem;
      arr[g] = arr[g] / 10;
    }
    pro = pro * pow(9, g);
    k = max(k, pro);
    i = i / 10;
  }
  long long pro1 = 1;
  while (arr[0] != 0) {
    rem = arr[0] % 10;
    pro1 = pro1 * rem;
    arr[0] = arr[0] / 10;
  }
  cout << max(k, pro1) << endl;
  return 0;
}
