string solve(string num, int len){ int n = stoi(num), a = 0, b = 0; switch (len) { case4: a = n / 100; b = n % 100; if (a > 9) a = (a / 10) * (a % 10); if (b > 9) b = (b / 10) * (b % 10); if (a == 0) returnto_string(b); num = to_string(a) + to_string(b); return num; case3: a = (n / 100) * ((n / 10) % 10); b = ((n / 10) % 10) * (n % 10); num = to_string(a) + to_string(b); return num; case2: a = n / 10; b = n % 10; num = to_string(a * b); return num; default: return"0"; } return"0"; }
intmain(){ string num; cin >> num;
while (num.size() != 1) { num = solve(num, num.size()); } cout << num; return0; }