#include <bits/stdc++.h>
using namespace std;
long long xx, dem = 1, l = 1, r;
int product(int x) {
  int prod = 1;
  while (x) {
    prod *= (x % 10);
    x /= 10;
  }
  return prod;
}
long long findNumber(long long l, long long r) {
  string a = to_string(l);
  string b = to_string(r);
  long long ans = r;
  for (int i = 0; i < b.size(); i++) {
    if (b[i] == '0') continue;
    string curr = b;
    curr[i] = ((curr[i] - '0') - 1) + '0';
    for (int j = i + 1; j < curr.size(); j++) curr[j] = '9';
    long long num = 0;
    for (auto c : curr) num = num * 10 + (c - '0');
    if (num >= l && product(ans) < product(num)) ans = num;
  }
  return ans;
}
int main() {
  cin >> r;
  xx = findNumber(l, r);
  while (xx != 0) {
    dem *= (xx % 10);
    xx = xx / 10;
  }
  cout << dem;
  return 0;
}
