import java.util.Scanner;
public class Main {
static int multiplication(int x) {
int mul = 1;
while(x != 0) {
mul *= x % 10;
x /= 10;
}
return mul;
}
public static void main
(String[] args
) { Scanner scanner
= new Scanner
(System.
in); int n = scanner.nextInt();
int maxmul = multiplication(n);
int copy = n;
int i = 10;
while(n!= 0) {
int temporary_number = (copy / (i / 10)) % 10;
int left = copy / i;
int right = copy % (i / 10);
if(temporary_number != 9) {
temporary_number = 9;
copy = ((left - 1) * 10 + temporary_number) * (i / 10) + right;
}
n /= 10;
i *= 10;
int mul = multiplication(copy);
if(maxmul < mul) maxmul = mul;
}
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwpwdWJsaWMgY2xhc3MgTWFpbiB7CglzdGF0aWMgaW50IG11bHRpcGxpY2F0aW9uKGludCB4KSB7CgkJICAgIGludCBtdWwgPSAxOwoJCSAgICB3aGlsZSh4ICE9IDApIHsKCQkgICAgICAgIG11bCAqPSB4ICUgMTA7CgkJICAgICAgICB4IC89IDEwOwoJCSAgICB9CgkJICAgIHJldHVybiBtdWw7Cgl9CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgewoJCVNjYW5uZXIgc2Nhbm5lciA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkJaW50IG4gPSBzY2FubmVyLm5leHRJbnQoKTsKCQlpbnQgbWF4bXVsID0gbXVsdGlwbGljYXRpb24obik7CgkJaW50IGNvcHkgPSBuOwoJCWludCBpID0gMTA7CgkJd2hpbGUobiE9IDApIHsKCQkJaW50IHRlbXBvcmFyeV9udW1iZXIgPSAoY29weSAvIChpIC8gMTApKSAlIDEwOwoJCQlpbnQgbGVmdCA9IGNvcHkgLyBpOwoJCQlpbnQgcmlnaHQgPSBjb3B5ICUgKGkgLyAxMCk7CgkJCWlmKHRlbXBvcmFyeV9udW1iZXIgIT0gOSkgewoJCQkJdGVtcG9yYXJ5X251bWJlciA9IDk7CgkJCQljb3B5ID0gKChsZWZ0IC0gMSkgKiAxMCArIHRlbXBvcmFyeV9udW1iZXIpICogKGkgLyAxMCkgKyByaWdodDsKCQkJfQoJCQluIC89IDEwOwoJCQlpICo9IDEwOwoJCQlpbnQgbXVsID0gbXVsdGlwbGljYXRpb24oY29weSk7CgkJCWlmKG1heG11bCA8IG11bCkgbWF4bXVsID0gbXVsOwoJCX0KCQlTeXN0ZW0ub3V0LnByaW50bG4obWF4bXVsKTsKCX0KCQp9