#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long best = 1, nr9 = 1;
  for (int i = (int)s.size() - 1; i >= 0; i--) {
    long long op1 = (s[i] - '0') * best;
    long long op2 = (s[i] - '0' - 1) * nr9;
    best = max(op1, op2);
    nr9 *= 9;
  }
  cout << max(best, nr9 / 9);
  return 0;
}
