#include <bits/stdc++.h>
using namespace std;
vector<long long> pr;
long long prime[1001];
void sieve(long long n) {
  long long i, j;
  for (i = 0; i <= n; i++) {
    prime[i] = 1;
  }
  prime[0] = 0;
  prime[1] = 0;
  for (i = 0; i <= sqrt(n); i++) {
    if (prime[i] == 1) {
      for (j = 2; i * j <= n; j++) {
        prime[i * j] = 0;
      }
    }
  }
  for (i = 2; i <= n; i++) {
    if (prime[i] == 1) pr.push_back(i);
  }
}
long long mult(long long n) {
  if (n < 10) {
    return max(1ll, n);
  }
  return max((n % 10) * mult(n / 10), 9 * mult(n / 10 - 1));
}
int main() {
  long long n;
  cin >> n;
  cout << mult(n) << endl;
}
