#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, r, s, prod, res, mx, t;
  int a[500];
  cin >> n;
  i = 0;
  int x = n;
  s = x;
  while (x) {
    a[i] = x % 10;
    x = x / 10;
    i++;
  }
  if (i == 1) {
    cout << n << '\n';
  } else if (i == 2) {
    mx = 0;
    while (s) {
      res = 1;
      k = s % 10;
      t = s / 10;
      if (t == 0) {
        res = k;
      }
      if (t != 0 && k != 0) res = t * k;
      if (res > mx) mx = res;
      s--;
    }
    cout << mx << '\n';
  } else {
    res = 1;
    for (j = i - 1; j >= 0; j--) {
      res = res * a[j];
    }
    mx = 0;
    if (res > mx) mx = res;
    for (j = i - 1; j >= 0; j--) {
      res = 1;
      int p = a[j];
      if (a[j] == 1) {
        res = 9;
        j--;
        k = j;
        k--;
        for (int l = k; l >= 0; l--) {
          res = res * 9;
        }
        for (int l = j + 1; l < i; l++) {
          res = res * a[l];
        }
      } else if (a[j] == 0) {
      } else {
        res = a[j] - 1;
        k = j;
        k--;
        for (int l = k; l >= 0; l--) {
          res = res * 9;
        }
        for (int l = j + 1; l < i; l++) {
          res = res * a[l];
        }
      }
      if (res > mx) mx = res;
    }
    cout << mx << '\n';
  }
  return 0;
}
