#include <bits/stdc++.h>
using namespace std;
vector<int> vector1;
bool symbol = false;
int N;
long long finds(int i) {
  if (i < 10) return max(1, i);
  return max((i % 10) * finds(i / 10), 9 * finds(i / 10 - 1));
}
int main() {
  while (cin >> N && N != 0) {
    cout << finds(N) << endl;
  }
  return 0;
}
