#include #define rep(i, n) for(int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int INF = (1LL << 30) - 1; int MOD = 1e9+7; main(){ string S; cin >> S; ll sum = 0; int cnt[10] = {}; for(auto c:S){ sum += c - '0'; cnt[c - '0']++; } int bit = 0; rep(i,9){ bit += ((bool)cnt[i+1]) << i; } if(__builtin_popcount(bit) == 1 && !cnt[0]){ cout << S << endl; return 0; } int ans = 1; if(sum % 9 == 0)ans *= 9; else if(sum % 3 == 0)ans *= 3; if(bit == 0b000010000) ans *= 5; if(!(bit & 0b101111111))ans *= 8; else if(!(bit & 0b101110111))ans *= 4; else if(!(bit & 0b101010101))ans *= 2; cout << ans << endl; }