#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n;
  cin >> n;
  int d = 0;
  unsigned long long ans = 1;
  unsigned long long ans2 = 1;
  vector<int> v;
  vector<int>::iterator p;
  while (n > 0) {
    d = n % 10;
    v.push_back(d);
    n /= 10;
  }
  int s = v.size();
  unsigned long long a[s];
  p = v.begin();
  for (int i = s - 1; i >= 0; i--) {
    a[i] = *p;
    p++;
  }
  bool check = false;
  if (s == 1) {
    cout << a[0] << endl;
  } else {
    if (a[0] == 1) {
      for (int i = 1; i < s; i++) {
        a[i] = 9;
        ans *= a[i];
      }
      cout << ans << endl;
    } else {
      for (int i = 1; i < s; i++) {
        ans2 *= 9;
      }
      ans2 *= (a[0] - 1);
      for (int i = 0; i < s; i++) {
        if (i != s - 1) {
          if (a[i] > a[i + 1] && check == 0) {
            a[i]--;
            check = true;
          } else if (check == 1) {
            a[i] = 9;
          }
        } else if (check == 1) {
          a[s - 1] = 9;
        }
      }
      for (int i = 0; i < s; i++) {
        ans *= a[i];
      }
      cout << max(ans, ans2) << endl;
    }
  }
}
