#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int v, n = 0, j, i, n1 = 0, c = 0, d = 0, m = 1, i1;
  cin >> n;
  n1 = n;
  if (n1 < 10) {
    cout << n1 << "\n";
    return 0;
  }
  while (n1 > 0) {
    n1 = n1 / 10;
    d++;
  }
  string s = to_string(n);
  long long int ans, a2 = n, f1 = 0, f = 0, p1 = 1, p2 = 1;
  ans = n;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '0') continue;
    string present = s;
    present[i] = ((present[i] - '0') - 1) + '0';
    for (j = i + 1; j < present.size(); j++) present[j] = '9';
    int num = 0;
    f = 0;
    for (i1 = 0; i1 < present.size(); i1++) f = f * 10 + (present[i1] - '0');
    f1 = f;
    a2 = ans;
    while (f1 > 0) {
      p1 = p1 * (f1 % 10);
      f1 = f1 / 10;
    }
    while (a2 > 0) {
      p2 = p2 * (a2 % 10);
      a2 = a2 / 10;
    }
    if (p1 > p2) ans = f;
    p1 = 1;
    p2 = 1;
  }
  a2 = ans;
  while (a2 > 0) {
    p2 = p2 * (a2 % 10);
    a2 = a2 / 10;
  }
  cout << p2 << "\n";
}
