#include #include using namespace std; using mint = atcoder::modint998244353; int main() { string s; cin >> s; int n = s.size(); vector S0(n + 1), Sq(n + 1); for (int i = 0; i < n; i++) { S0[i + 1] = S0[i] + (s[i] == '0'); Sq[i + 1] = Sq[i] + (s[i] == '?'); } mint ans = 0; const mint inv2 = mint(2).inv(); for (int i = 0; i < n; i++) { mint L = S0[i] + Sq[i] * inv2; mint R = (S0[n] - S0[i + 1]) + (Sq[n] - Sq[i + 1]) * inv2; mint E = L * R; if (s[i] == '0') E = 0; else if (s[i] == '?') E *= inv2; ans += E; } ans *= mint(2).pow(Sq[n]); cout << ans.val() << "\n"; }