#include <bits/stdc++.h>
using namespace std;
long long int solve(long long int n) {
  if (n < 10) {
    return max(1ll, n);
  }
  return max((n % 10) * solve(n / 10), 9 * solve(n / 10 - 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int n;
  cin >> n;
  cout << solve(n) << endl;
}
