#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX_N = 2e5 + 10;
int n;
int nDigit;
int digits[15];
int ans = 0;
long long quickPow(long long a, long long x) {
  long long res = 1;
  while (x > 0) {
    if (x & 1) res *= a;
    a *= a;
    x >>= 1;
  }
  return res;
}
int getIndex(int x) {
  int res = 0;
  while (x > 0) {
    ++res;
    x /= 10;
  }
  return res - 1;
}
void solve(int index, int nowRes) {
  if (index == -1) {
    if (ans < nowRes) ans = nowRes;
    return;
  }
  solve(index - 1, nowRes * digits[index]);
  if (digits[index] > 1)
    nowRes *= digits[index] - 1;
  else if (index != nDigit - 1)
    return;
  nowRes *= quickPow(9, index);
  if (ans < nowRes) ans = nowRes;
}
int main() {
  scanf("%d", &n);
  nDigit = 0;
  while (n > 0) {
    digits[nDigit++] = n % 10;
    n /= 10;
  }
  solve(nDigit - 1, 1);
  printf("%d\n", ans);
  return 0;
}
