#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 1e9 + 5;
const long long mod = 1e9 + 7;
const double pi = 3.1415926536;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  string s;
  cin >> s;
  int n = s.size();
  long long ans = 1;
  for (int i = 0; i < n; i++) ans *= (s[i] - '0');
  long long mx = ans;
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] != '0') {
      s[i]--;
      s[i + 1] = '9';
      ans = 1;
      for (int j = 0; j < n; j++) {
        if (s[j] == '0' && j == 0) continue;
        ans *= s[j] - '0';
      }
      mx = max(mx, ans);
    } else {
      s[i + 1] = '9';
    }
  }
  cout << mx << endl;
  return 0;
}
