#include <iostream>
using namespace std;
int main()
{
int n; cin >> n; // 1620
while(n >= 10)
{
int a[6] = {0};
int cnt = 1, sum = 1;
while(n > 0)
{
a[cnt] = n % 10;
n /= 10;
cnt++;
}
for(int i = 1; i <= 6; i++)
{
if(a[i] != 0)
{
sum *= a[i];
}
}
n = sum;
}
cout << n << endl;
return 0;
}