#include <bits/stdc++.h>
using namespace std;
int64_t pw(int64_t b, int64_t p) {
  int64_t ans = 1;
  while (p--) ans *= b;
  return ans;
}
int64_t mn(int64_t mx) {
  if (mx >= 10) {
    int64_t fd = mx, p10 = 0;
    while (fd > 9) {
      fd /= 10;
      p10++;
    }
    if (fd == 1) {
      return max(pw(9, p10), fd * mn(mx % pw(10, p10)));
    } else {
      return max((fd - 1) * pw(9, p10), fd * mn(mx % pw(10, p10)));
    }
  }
  return mx;
}
int main() {
  int64_t n;
  cin >> n;
  cout << mn(n) << endl;
}
