#include using namespace std; constexpr int mod = 998244353; int dp[200200][4]; void mpl(int &x,int y) { x += y; if(x >= mod) x -= mod; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string S; cin >> S; dp[0][0] = 1; for(int i = 0; i < S.size(); i++) { for(int j = 0; j < 4; j++) { mpl(dp[i+1][j],dp[i][j]); if(S[i] == '0' && (j == 0 || j == 2)) { mpl(dp[i+1][j+1],dp[i][j]); } if(S[i] == '1' && j == 1) { mpl(dp[i+1][j+1],dp[i][j]); } if(S[i] == '?' && j < 3) { mpl(dp[i+1][j+1],dp[i][j]); } if(S[i] == '?') { mpl(dp[i+1][j],dp[i][j]); } } } cout << dp[S.size()][3] << "\n"; }