#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")
using namespace std;
mt19937 gen(42);
long long step[14];
string n;
long long res(string s) {
  long long ans = 0;
  if (s[0] > '1') ans = (s[0] - '1') * step[s.size() - 1];
  if (s[0] == '1') ans = step[s.size() - 1];
  long long res = s[0] - '0';
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == '0') break;
    if (s[i] > '1') ans = max(ans, res * (s[i] - '1') * step[s.size() - i - 1]);
    res *= (s[i] - '0');
  }
  return max(ans, res);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  step[0] = 1;
  for (int i = 1; i <= 13; i++) step[i] = step[i - 1] * 9;
  cout << res(n);
  return 0;
}
