#include <bits/stdc++.h>
using namespace std;
long long calc(string t) {
  long long sum = 1;
  int i = 0;
  if (t[i] == '0') i++;
  for (; i < t.size(); i++) {
    sum *= (t[i] - '0');
  }
  return sum;
}
int main() {
  string s;
  cin >> s;
  long long ans = calc(s);
  for (int i = 0; i < s.size() - 1; i++) {
    string temp;
    for (int j = 0; j <= i; j++) {
      temp += s[j];
    }
    temp[i] = temp[i] - 1;
    for (int j = i + 1; j < s.size(); j++) temp += '9';
    ans = max(ans, calc(temp));
  }
  cout << ans;
}
