#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) return _out;
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) _in >> _i;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty()) return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it;
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty()) return _out;
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it)
    _out << ", (" << _it->first << ": " << _it->second << ')';
  return _out;
}
int solve(vector<int> nums, int begin, int end) {
  while (begin < end && nums[begin] == 0) ++begin;
  if (begin == end) return nums[begin];
  int ans = max((nums[begin] - 1), 1);
  for (int i = begin; i < end; ++i) ans *= 9;
  return max(ans, nums[begin] * solve(nums, begin + 1, end));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long curr = n;
  vector<int> nums;
  while (curr > 0) {
    nums.push_back(curr % 10);
    curr = curr / 10;
  }
  reverse(nums.begin(), nums.end());
  int ans = solve(nums, 0, nums.size() - 1);
  cout << ans << endl;
  return 0;
}
