#include <iostream>
using namespace std;
const int TEN = 10;
int main() {
int n;
cin >> n;
while (n >= TEN) {
int result = 1, copyN = n;
while (copyN > 0) {
int digit = copyN % TEN;
result *= digit;
copyN /= TEN;
}
n = result;
}
cout << n;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IFRFTiA9IDEwOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgd2hpbGUgKG4gPj0gVEVOKSB7CiAgICAgICAgaW50IHJlc3VsdCA9IDEsIGNvcHlOID0gbjsKICAgICAgICB3aGlsZSAoY29weU4gPiAwKSB7CiAgICAgICAgICAgIGludCBkaWdpdCA9IGNvcHlOICUgVEVOOwogICAgICAgICAgICByZXN1bHQgKj0gZGlnaXQ7CiAgICAgICAgICAgIGNvcHlOIC89IFRFTjsKICAgICAgICB9CiAgICAgICAgbiA9IHJlc3VsdDsKICAgIH0KICAgIGNvdXQgPDwgbjsKICAgIHJldHVybiAwOwp9