#include <bits/stdc++.h>
using namespace std;
int n, i, p, ci, pmax, xmax;
char s[20];
int calcprod(char s[], int n) {
  int p = 1;
  for (int i = 0; i <= n; i++) p = p * (s[i] - '0');
  return p;
}
int main() {
  p = 1;
  pmax = 0;
  cin >> s;
  n = strlen(s);
  i = n - 1;
  while (i >= 0) {
    int pp = calcprod(s, n - 1);
    pmax = max(pmax, pp);
    s[i] = '9';
    i--;
    while (i >= 0 && s[i] == '0') {
      s[i] = '9';
      i--;
    }
    if (!(i == 0 && s[i] == '1')) s[i]--;
    xmax = pmax;
  }
  cout << xmax;
  return 0;
}
