#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, k, ans, pro;
  string a, b;
  cin >> b;
  n = b.size();
  ans = -1e9 + 7;
  pro = 1;
  for (i = 0; i < n; i++) {
    pro = pro * (b[i] - '0');
  }
  if (pro > ans) {
    ans = pro;
  }
  for (i = 0; i < n; i++) {
    a = b;
    if (a[i] == '0') {
      continue;
    }
    a[i] = a[i] - 1;
    for (j = i + 1; j < n; j++) {
      a[j] = '9';
    }
    pro = 1;
    for (j = 0; j < n; j++) {
      if (i == j && a[j] == '0') {
        continue;
      }
      pro = pro * (a[j] - '0');
    }
    if (pro > ans) {
      ans = pro;
    }
  }
  if (b.size() == 1) {
    ans = b[0] - '0';
  }
  printf("%lld\n", ans);
  return 0;
}
