#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  string str1 = str;
  long long int n = str.length();
  if (n == 1) {
    cout << str[0];
    return 0;
  }
  long long int t = 0;
  long long int z = 0;
  long long int str2[n];
  str2[0] = str[0] - 48;
  for (int i = 1; i < n; i++) {
    str2[i] = str2[i - 1] * (str[i] - 48);
  }
  long long int coun = str2[n - 1];
  for (int i = 1; i < n; i++) {
    if (str2[i] == 0) {
      break;
    }
    if (str[i] == 1) {
      continue;
    }
    if (i + 1 < n and i != 0) {
      long long int m = str2[i - 1] * (str[i] - 49) * pow(9, n - i - 1);
      coun = max(coun, m);
    }
  }
  long long int a[n];
  n--;
  long long int k1 = str1[0] - 1 - 48;
  if (k1 == 0) {
    k1 = 1;
  }
  if (coun < pow(9, n) * k1) {
    coun = pow(9, n) * k1;
  }
  cout << coun;
  return 0;
}
