#include <iostream>
using namespace std;
int multiplication(int x) {
int mul = 1;
while(x != 0) {
mul *= x % 10;
x /= 10;
}
return mul;
}
int main() {
int n;
cin >> n;
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;
}
cout << maxmul;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG11bHRpcGxpY2F0aW9uKGludCB4KSB7CglpbnQgbXVsID0gMTsKCXdoaWxlKHggIT0gMCkgewoJCW11bCAqPSB4ICUgMTA7CgkJeCAvPSAxMDsKCX0KCXJldHVybiBtdWw7Cn0KaW50IG1haW4oKSB7CiAgaW50IG47CiAgY2luID4+IG47CiAgaW50IG1heG11bCA9IG11bHRpcGxpY2F0aW9uKG4pOyAgCiAgaW50IGNvcHkgPSBuOwogIGludCBpID0gMTA7CiAgd2hpbGUobiAhPSAwKSB7CgkgIGludCB0ZW1wb3JhcnlfbnVtYmVyID0gKGNvcHkgLyAoaSAvIDEwKSkgJSAxMDsKCSAgaW50IGxlZnQgPSBjb3B5IC8gaTsKCSAgaW50IHJpZ2h0ID0gY29weSAlIChpIC8gMTApOwoJICBpZih0ZW1wb3JhcnlfbnVtYmVyICE9IDkpIHsKCSAgICB0ZW1wb3JhcnlfbnVtYmVyID0gOTsKCSAgICBjb3B5ID0gKChsZWZ0IC0gMSkgKiAxMCArIHRlbXBvcmFyeV9udW1iZXIpICogKGkgLyAxMCkgKyByaWdodDsKCSAgfQoJICBuIC89IDEwOwoJICBpICo9IDEwOwoJICBpbnQgbXVsID0gbXVsdGlwbGljYXRpb24oY29weSk7CgkgIGlmKG1heG11bCA8IG11bCkgbWF4bXVsID0gbXVsOwoJfSAgCgljb3V0IDw8IG1heG11bDsgCn0=