#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
char s[15];
long long qmod(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a = a * a;
  }
  return res;
}
int main() {
  cin >> s;
  int len = strlen(s);
  long long n = 0, ans = 1, tmp = 0;
  ;
  for (int i = 0; i < len; i++) {
    n = n * 10 + (s[i] - '0');
    ans = ans * (s[i] - '0');
  }
  for (int i = 0; i < len; i++) {
    int t = s[i] - '1';
    if (t == 0) t = 1;
    long long m = 1;
    for (int j = 0; j < i; j++) m = m * (s[j] - '0');
    m *= t;
    tmp = 1ll * m * qmod(9, len - i - 1);
    ans = max(ans, tmp);
  }
  printf("%I64d\n", ans);
  return 0;
}
