#include <bits/stdc++.h>
using namespace std;
int n, num, ma(0);
vector<int> v;
void make() {
  while (n) {
    v.push_back(n % 10);
    n /= 10;
  }
  n = v.size();
  reverse(v.begin(), v.end());
}
int take() {
  int mult(1);
  for (int i = 0; i < n; ++i) mult *= v[i];
  return mult;
}
void f() {
  ma = max(ma, take());
  for (int i = n - 1; i > 0; --i) {
    v[i] = 9;
    if (v[i - 1] != 0) {
      if (i != 1 || v[0] != 1) --v[i - 1];
    }
    if (take() > ma) {
      ma = take();
    }
  }
}
int main() {
  cin >> n;
  make();
  f();
  cout << ma;
  return 0;
}
