#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const int MOD = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
template <class T>
T read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
  return x;
}
int bd = 0;
int pd(string x) {
  int ans = 1;
  for (int i = 0; i < x.length(); ++i) {
    if (i != 0 || x[i] != '0') ans *= x[i] - '0';
  }
  return ans;
}
int main() {
  string s;
  cin >> s;
  bd = pd(s);
  for (int i = s.length() - 1; i; --i) {
    s[i] = '9';
    --s[i - 1];
    bd = max(bd, pd(s));
  }
  cout << bd << endl;
  return 0;
}
