#include <bits/stdc++.h>
using namespace std;
string num;
long long memo[12][2][2];
long long dp(int pos, bool lt, bool nz) {
  if (pos == num.size()) return nz ? 1 : 0;
  if (memo[pos][lt][nz] != -1) return memo[pos][lt][nz];
  int lmt = 9;
  if (!lt) lmt = num[pos] - '0';
  long long res = 0;
  for (int d = 0; d <= lmt; d++) {
    long long cur = d * 1LL;
    if (d == 0 && !nz) cur = 1;
    bool nlt = lt | (d < lmt);
    long long nxt = dp(pos + 1, nlt, d > 0);
    res = max(res, cur * nxt);
  }
  return memo[pos][lt][nz] = res;
}
int main() {
  cin >> num;
  memset(memo, -1, sizeof(memo));
  cout << dp(0, 0, 0) << '\n';
  return 0;
}
