#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, i, j, k, f = 0, m = 0, mul = 1;
  cin >> n;
  vector<int> num;
  j = n;
  while (j > 0) {
    k = j % 10;
    num.push_back(k);
    j = j / 10;
  }
  reverse(num.begin(), num.end());
  if (num.size() == 1) {
    cout << n;
    return 0;
  }
  k = num[0];
  i = num.size() - 1;
  while (i > 0) {
    if (num[i] == 0) {
      while (num[i] == 0 && i > 0) {
        num[i] = 9;
        i--;
      }
      num[i] = num[i] - 1;
    } else if (num[i] != 0 && num[i] != 9) {
      num[i] = 9;
      num[i - 1]--;
    } else
      i--;
    mul = 1;
    for (j = 0; j < num.size(); j++) {
      if (j == 0 && num[j] == 0) continue;
      mul = mul * num[j];
    }
    m = max(m, mul);
  }
  long long int mul1 = 1;
  j = n;
  while (j > 0) {
    k = j % 10;
    mul1 = mul1 * k;
    j = j / 10;
  }
  cout << max(m, mul1);
}
