#include <bits/stdc++.h>
using namespace std;
long long int solve() {
  long long int n;
  cin >> n;
  if (n < 10) return n;
  vector<int> data;
  long long int p = 1;
  while (n) {
    data.push_back(n % 10);
    n /= 10;
    p *= 9;
  }
  p /= 9;
  long long int ans = p, cur = 1;
  for (int i = data.size() - 1; i >= 0; i--) {
    if (data[i] == 0) return ans;
    ans = max(ans, cur * p * (data[i] - 1));
    p /= 9;
    cur *= data[i];
  }
  return max(ans, cur);
}
int main() { cout << solve() << endl; }
