#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[10] = {0};
  int a = n;
  for (int i = 0; i < 10; i++) {
    arr[i] = a % 10;
    a = a / 10;
  }
  long long int ans = 0;
  int z = 1;
  for (int i = 9; i >= 0; i--) {
    if (arr[i] == 0) {
      continue;
    } else {
      long long temp = pow(9, i);
      if (arr[i] != 1) {
        temp = temp * (arr[i] - 1);
      }
      temp = temp * z;
      z = z * arr[i];
      if (temp > ans) {
        ans = temp;
      }
    }
  }
  if (z > ans) {
    ans = z;
  }
  cout << ans << endl;
}
