s = input() mod = 998244353 n = len(s) LtoR = [[0 for _ in range(3)] for _ in range(n + 1)] RtoL = [[0 for _ in range(3)] for _ in range(n + 1)] for i in range(n): if s[i] == '0': LtoR[i + 1][0] = LtoR[i][0] + 1 LtoR[i + 1][1] = LtoR[i][1] LtoR[i + 1][2] = LtoR[i][2] elif s[i] == '1': LtoR[i + 1][0] = LtoR[i][0] LtoR[i + 1][1] = LtoR[i][1] + 1 LtoR[i + 1][2] = LtoR[i][2] else: LtoR[i + 1][0] = LtoR[i][0] LtoR[i + 1][1] = LtoR[i][1] LtoR[i + 1][2] = LtoR[i][2] + 1 for i in range(n - 1, -1, -1): if s[i] == '0': RtoL[i][0] = RtoL[i + 1][0] + 1 RtoL[i][1] = RtoL[i + 1][1] RtoL[i][2] = RtoL[i + 1][2] elif s[i] == '1': RtoL[i][0] = RtoL[i + 1][0] RtoL[i][1] = RtoL[i + 1][1] + 1 RtoL[i][2] = RtoL[i + 1][2] else: RtoL[i][0] = RtoL[i + 1][0] RtoL[i][1] = RtoL[i + 1][1] RtoL[i][2] = RtoL[i + 1][2] + 1 ans = 0 for i in range(1, n - 1): if s[i] == '1' or s[i] == '?': ans += pow(2, LtoR[i][2] + RtoL[i + 1][2], mod) * LtoR[i][0] % mod * RtoL[i + 1][0] % mod ans %= mod if LtoR[i][2] > 0: ans += LtoR[i][2] * pow(2, LtoR[i][2] - 1, mod) % mod * LtoR[i + 1][0] % mod ans %= mod if RtoL[i + 1][2] > 0: ans += LtoR[i][0] * RtoL[i + 1][2] % mod * pow(2, RtoL[i + 1][2] - 1, mod) % mod ans %= mod if LtoR[i][2] > 0 and RtoL[i + 1][2] > 0: ans += LtoR[i][2] * RtoL[i + 1][2] % mod * pow(2, LtoR[i][2] + RtoL[i + 1][2] - 2, mod) % mod ans %= mod print(ans)