#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long cnt(string s) {
  while (s.size() && s[0] == '0') {
    s = s.substr(1, s.size() - 1);
  }
  long long ans = 1;
  for (auto e : s) {
    ans *= e - '0';
  }
  return ans;
}
signed main() {
  fast();
  string s;
  cin >> s;
  long long ans = cnt(s);
  for (long long i = 1; i <= s.size(); ++i) {
    string tmp;
    for (long long j = 0; j < i; ++j) {
      tmp.push_back(s[j]);
    }
    if (tmp.back() > '0') {
      --tmp.back();
      while (tmp.size() < s.size()) tmp.push_back('9');
      ans = max(ans, cnt(tmp));
    }
  }
  cout << ans << '\n';
  return 0;
}
