#include <bits/stdc++.h>
using namespace std;
const int N = 11;
long long g_d[N][2];
int main() {
  int n, i;
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i < N; i++) {
      long long mod = (long long)(pow(10, i) + 0.5);
      long long t = n % mod;
      long long k = t / (mod / 10);
      if (i == 1)
        g_d[i][0] = g_d[i][1] = t;
      else {
        g_d[i][0] = (k - 1 <= 0 ? 1 : k - 1) * (long long)(pow(9, i - 1) + 0.5);
        g_d[i][1] = max(k * g_d[i - 1][0], k * g_d[i - 1][1]);
      }
      if (t == n) break;
    }
    printf("%I64d\n", max(g_d[i][0], g_d[i][1]));
  }
  return 0;
}
