#include <bits/stdc++.h>
using namespace std;
string str;
long long mypow(int a, int b) {
  long long ret = 1;
  for (int i = 1; i <= b; i++) ret *= a;
  return ret;
}
int main() {
  int i, j;
  cin >> str;
  if (str.size() == 1) return cout << str << endl, 0;
  long long ans = mypow(9, (str.size() - 1));
  long long sum = 1;
  for (i = 0; i < str.size(); i++) {
    char ch = str[i];
    int baki = str.size() - i - 1;
    long long now = sum * ((ch - '0') - 1) * mypow(9, baki);
    ans = max(ans, now);
    sum *= (ch - '0');
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
