#include <bits/stdc++.h>
using namespace std;
long long int f(long long int x) {
  long long int ans = 1;
  while (x) {
    ans = ans * (x % 10);
    x /= 10;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> p_10(11);
  p_10[0] = 1;
  for (long long int i = 1; i <= 10; i++) {
    p_10[i] = p_10[i - 1] * 10;
  }
  long long int ans = f(n);
  long long int num = 0;
  vector<long long int> dig;
  long long int n_ = n;
  while (n_) {
    dig.push_back(n_ % 10);
    num++;
    n_ /= 10;
  }
  for (long long int i = num - 1; i >= 0; i--) {
    if (dig[i] == 0) continue;
    long long int new_num = n;
    for (int j = 0; j <= i; j++) {
      new_num -= (dig[j] * p_10[j]);
    }
    new_num += ((dig[i] - 1) * p_10[i] + (p_10[i] - 1));
    ans = max(ans, f(new_num));
  }
  cout << ans;
  return 0;
}
