#include <bits/stdc++.h>
using namespace std;
int find(int number) {
  int x, ans = 1;
  while (number) {
    x = number % 10;
    number = number / 10;
    ans = ans * x;
  }
  return ans;
}
int main() {
  int n;
  int number = 0, x = 0, b = 1, max = 0, ans = 0, p, k;
  cin >> n;
  x = n;
  p = n;
  ans = find(n);
  while (x != 0) {
    int number = (x - 1) * b + (b - 1);
    x = x / 10;
    b = b * 10;
    max = find(number);
    if (max > ans) {
      ans = max;
    }
  }
  cout << ans << endl;
}
