#include <bits/stdc++.h>
using namespace std;
long long powermodm(long long x, long long n, long long M) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long power(long long _a, long long _b) {
  long long _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
void build() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  build();
  long long n;
  cin >> n;
  vector<long long> d;
  while (n) {
    d.push_back(n % 10);
    n /= 10;
  }
  reverse(d.begin(), d.end());
  long long ans = 1;
  for (long long i = 0; i < d.size(); i++) ans *= d[i];
  for (long long i = d.size() - 1; i > 0; i--) {
    if (d[i] < 9) d[i] = 9;
    d[i - 1]--;
    long long idx = 0, ans1 = 1;
    for (long long i = 0; i < d.size(); i++) {
      if (d[i] == 0)
        idx++;
      else
        break;
    }
    for (long long i = idx; i < d.size(); i++) ans1 *= d[i];
    ans = max(ans, ans1);
  }
  cout << ans;
  return 0;
}
