#include #include #include #include using mint = atcoder::modint998244353; int main() { std::string s; std::cin >> s; int n = s.size(); std::vector> dp(n + 1, std::vector(3)); mint count = 1; for (int i = 0; i < n; i++) { if (s[i] != '1') { dp[i + 1][0] += dp[i][0] + count; dp[i + 1][1] += dp[i][1]; dp[i + 1][2] += dp[i][2] + dp[i][1]; } if (s[i] != '0') { dp[i + 1][0] += dp[i][0]; dp[i + 1][1] += dp[i][1] + dp[i][0]; dp[i + 1][2] += dp[i][2]; } if (s[i] == '?') { count *= 2; } } std::cout << dp[n][2].val() << '\n'; }