#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long x = 1, mx = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '0') {
      x *= (s[i] - 48);
    }
  }
  mx = max(mx, x);
  x = 1;
  for (int i = s.size() - 1; i > 0; i--) {
    if (s[i] != '9') {
      s[i] = '9';
      s[i - 1]--;
    }
    for (int i = 0; i < s.size(); i++) {
      if (s[i] != '0') {
        x *= (s[i] - 48);
      }
    }
    mx = max(mx, x);
    x = 1;
  }
  cout << mx << "\n";
  return 0;
}
