MOD = 998244353 S = input()[::-1] three = 3 c0 = 2 * pow(3, -1, MOD) % MOD all_ = c0 t = c0 two = 1 ans = 0 for s in S: if s == "1": ans = (ans + two) % MOD all_ = (all_ * three) % MOD t = (t * c0) % MOD else: ans = (ans + two * t % MOD) % MOD three = (three * three) % MOD two = (two * 2) % MOD c0 = (c0 * c0) % MOD print(ans * all_ % MOD)