#include using namespace std; const int MOD = 998244353; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int n = (int)s.size(); s = "#" + s; vector> dp(n + 1); dp[0][0] = 1; for (int i = 1; i <= n; ++i) { if (s[i] == '0') { dp[i][0] = dp[i - 1][0]; dp[i][1] = (dp[i - 1][1] + dp[i - 1][0]) % MOD; dp[i][2] = dp[i - 1][2]; dp[i][3] = (dp[i - 1][3] + dp[i - 1][2]) % MOD; } else if (s[i] == '1') { dp[i][0] = dp[i - 1][0]; dp[i][1] = dp[i - 1][1]; dp[i][2] = (dp[i - 1][2] + dp[i - 1][1]) % MOD; dp[i][3] = dp[i - 1][3]; } else { dp[i][0] = dp[i - 1][0] * 2LL % MOD; dp[i][1] = (dp[i - 1][1] + dp[i - 1][1] + dp[i - 1][0]) % MOD; dp[i][2] = (dp[i - 1][2] + dp[i - 1][2] + dp[i - 1][1]) % MOD; dp[i][3] = (dp[i - 1][3] + dp[i - 1][3] + dp[i - 1][2]) % MOD; } } cout << dp[n][3] << endl; }