local mod = 998244353 local mfl = math.floor local function bmul(x, y) local x0, y0 = x % 31596, y % 31596 local x1, y1 = mfl(x / 31596), mfl(y / 31596) return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod end local function badd(x, y) return (x + y) % mod end local function bsub(x, y) return x < y and x - y + mod or x - y end local s = io.read() local n = #s local t = {} for i = 1, n do t[i] = s:sub(i, i) end local sum0 = {} local sum1 = {} if t[1] == "0" then sum0[1] = 1 else sum0[1] = 0 end if t[1] == "1" then sum1[1] = 1 else sum1[1] = 0 end for i = 2, n do if t[i] == "0" then sum0[i] = sum0[i - 1] + 1 else sum0[i] = sum0[i - 1] end if t[i] == "1" then sum1[i] = sum1[i - 1] + 1 else sum1[i] = sum1[i - 1] end end local tot0 = sum0[n] local tot1 = sum1[n] local totq = n - tot0 - tot1 local p2m1 = {1} for i = 2, 400000 do p2m1[i] = (p2m1[i - 1] * 2) % mod end local ans = 0 for i = 2, n - 1 do local left_0 = sum0[i - 1] local right_0 = tot0 - sum0[i] local left_1 = sum1[i - 1] local right_1 = tot1 - sum1[i] local left_q = i - 1 - left_0 - left_1 local right_q = n - i - right_0 - right_1 if t[i] == "1" then local v = bmul(left_0, right_0) v = bmul(v, p2m1[totq + 1]) ans = badd(ans, v) if 0 < left_q then v = bmul(left_q, right_0) v = bmul(v, p2m1[totq]) ans = badd(ans, v) end if 0 < right_q then v = bmul(left_0, right_q) v = bmul(v, p2m1[totq]) ans = badd(ans, v) end if 0 < left_q * right_q then v = bmul(left_q, right_q) v = bmul(v, p2m1[totq - 1]) ans = badd(ans, v) end elseif t[i] == "?" then local v = bmul(left_0, right_0) v = bmul(v, p2m1[totq]) ans = badd(ans, v) if 0 < left_q then v = bmul(left_q, right_0) v = bmul(v, p2m1[totq - 1]) ans = badd(ans, v) end if 0 < right_q then v = bmul(left_0, right_q) v = bmul(v, p2m1[totq - 1]) ans = badd(ans, v) end if 0 < left_q * right_q then v = bmul(left_q, right_q) v = bmul(v, p2m1[totq - 2]) ans = badd(ans, v) end end end print(ans)