#include <bits/stdc++.h>
using namespace std;
int main() {
  string nine =
      "99999999999999999999999999999999999999999999999999999999999999999999";
  long long res = 1, res2 = 1, res3 = 1, res4 = 1;
  string s, s2 = "111111111111111111111111111111";
  string s3 = s2;
  int x;
  cin >> x;
  s = to_string(x);
  int pos;
  for (int i = 0; i < s.length(); i++) res2 = res2 * (s[i] - '0');
  if (s.find('0') != string::npos) {
    s2 = s;
    pos = s2.find('0');
    s2[pos - 1] -= 1;
    s2 = s2.substr(0, pos) + nine.substr(0, s.length() - pos);
  }
  if (s.find('9') != string::npos) {
    s3 = s;
    pos = s3.find('9');
    s3[pos] -= 1;
    s3 = s3.substr(0, pos + 1) + nine.substr(0, s.length() - pos - 1);
  }
  if (x < 10)
    cout << x;
  else {
    if (s[0] == '1') {
      s = nine.substr(0, s.length() - 1);
    } else {
      if (max(s[0], s[1]) <= s[0]) {
        s = s[0] + nine.substr(0, s.length() - 1);
        s[0] -= 1;
      } else {
        s = s.substr(0, 2) + nine.substr(0, s.length() - 2);
        s[1] -= 1;
      }
    }
    for (int i = 0; i < s.length(); i++) {
      res = res * (s[i] - '0');
      res3 = res3 * (s2[i] - '0');
      res4 = res4 * (s3[i] - '0');
    }
    cout << max({res, res2, res3, res4});
  }
  return 0;
}
