#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long maxn = (long long)1e6 + 6;
const long double EPS = 1e-9;
const long long INF = (long long)1e18 + 18;
const long long mod = (long long)1e9 + 7;
string in;
long long brute(long long n) {
  long long ret = 0;
  for (long long i = 0; i <= n; i++) {
    long long p = 1;
    long long tmp = i;
    while (tmp) {
      p *= tmp % 10;
      tmp /= 10;
    }
    ret = max(ret, p);
  }
  return ret;
}
long long solve(long long number) {
  string in = to_string(number);
  long long n = (long long)in.length();
  long long ans = 1;
  long long p = 1;
  for (long long i = 0; i < n - 1; i++) {
    p *= 9;
  }
  for (long long i = 0; i < n; i++) {
    ans *= (in[i] - '0');
  }
  for (long long i = 0; i < n; i++) {
    long long curDigit = in[i] - '0';
    if (curDigit == 0) continue;
    long long remaining = n - i - 1;
    long long product = curDigit - 1;
    for (long long j = 0; j < i; j++) {
      product *= (in[j] - '0');
    }
    for (long long j = 0; j < remaining; j++) {
      product *= 9;
    }
    ans = max(ans, product);
  }
  ans = max(ans, p);
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long input;
  cin >> input;
  cout << solve(input) << '\n';
  return 0;
}
