S = input() zero = 0 h = 0 for s in S: if s == "0": zero += 1 elif s == "?": h += 1 P = 998244353 hz = 0 hh = 0 ans = 0 for s in S: if s == "1": t1 = hz * (hh + 1) + hh * pow(2,hh - 1,P) t2 = zero * (h + 1) + h * pow(2,h - 1,P) ans += t1 * t2 % P ans %= P elif s == "?": h -= 1 t1 = hz * (hh + 1) + hh * pow(2,hh - 1,P) t2 = zero * (h + 1) + h * pow(2,h - 1,P) ans += t1 * t2 % P ans %= P hh += 1 else: zero -= 1 hz += 1 #print(ans) print(ans)