#include <bits/stdc++.h>
using namespace std;
long long n;
long long ans;
long long dfs(long long now) {
  if (now == 0) {
    return 1;
  }
  if (now < 10) return now;
  return max(dfs(now / 10) * (now % 10), dfs(now / 10 - 1) * 9);
}
int main() {
  cin >> n;
  ans = dfs(n);
  cout << ans << endl;
  return 0;
}
