#include <bits/stdc++.h>
using namespace std;
int coun = 0;
int digit[11] = {0};
int solve(int p) {
  if (p == coun) return digit[p - 1];
  int j;
  int base = 1;
  int flag = 0;
  for (j = 0; j < p; j++) {
    base *= 9;
    if (digit[j] != 9) flag = 1;
  }
  while (flag == 1 && digit[j] == 0 && j < coun - 1) {
    digit[j] = 9;
    j++;
  }
  digit[j] -= flag;
  if (digit[j] == 0 && j == coun - 1) coun--;
  for (int j = p; j < coun; j++) base *= digit[j];
  return base;
}
int main() {
  int n;
  cin >> n;
  int t = n;
  int ans = 1;
  while (t != 0) {
    digit[coun] = t % 10;
    ans *= digit[coun];
    t /= 10;
    coun++;
  }
  for (int i = 1; i < coun; i++) {
    ans = max(ans, solve(i));
  }
  cout << ans;
  return 0;
}
