import sys inputs = sys.stdin.readline MOD = 998244353 """再帰関数のときセット sys.setrecursionlimit(10**7) import pypyjit pypyjit.set_param('max_unroll_recursion=-1') """ def main(): S = input() total_q = S.count('?') base_cnt = pow(2, total_q, MOD) half_cnt = pow(2, total_q - 1, MOD) rev2 = pow(2, MOD - 2, MOD) cnt_0 = 0 cnt_01 = 0 ans = 0 for s in S: if s == '0': ans = (ans + cnt_01) % MOD cnt_0 = (cnt_0 + base_cnt) % MOD elif s == '1': cnt_01 = (cnt_01 + cnt_0) % MOD else: ans = (ans + cnt_01 * rev2 % MOD) % MOD cnt_01 = (cnt_01 + cnt_0 * rev2 % MOD) % MOD cnt_0 = (cnt_0 + half_cnt) % MOD print(ans) if __name__ == '__main__': main()