#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v;
  while (n > 0) {
    v.push_back(n % 10);
    n /= 10;
  }
  reverse(v.begin(), v.end());
  int sz = v.size();
  long long ans = 0;
  for (int i = 1; i < sz; i++) {
    long long prod = 1;
    if (v[i] - 1 > 0) {
      prod = v[i] - 1;
      for (int j = 0; j < sz; j++) {
        if (j < i)
          prod *= v[j];
        else if (j > i)
          prod *= 9LL;
      }
      if (prod > ans) ans = prod;
    }
  }
  long long prod = 1;
  for (int i = 0; i < sz - 1; i++) prod *= 9;
  prod *= (v[0] > 1 ? v[0] - 1 : 1);
  ans = max(ans, prod);
  prod = 1;
  for (int i = 0; i < sz; i++) prod *= v[i];
  ans = max(ans, prod);
  cout << ans;
  return 0;
}
