#include using namespace std; using ll = long long; ll const m = 998244353; ll mpow(ll a, ll n) { ll ret = 1; while (n) { if (n & 1) { ret = (ret * a) % m; } a = (a * a) % m; n >>= 1; } return ret; } int main () { string s; cin >> s; ll hc = 0; if (s.size() < 3) { cout << 0 << endl; return 0; } ll zoz[4][4]; for (auto& a : zoz) { for (auto& b : a) { b = 0; } } zoz[0][0] = 1; for (auto c : s) { if (c == '?') { for (int i = 3; i > 0; i --) { for (int j = i; j > 0; j --) { zoz[j][i] += zoz[j - 1][i - 1]; zoz[j][i] %= m; } } hc ++; } else if (c == '1') { for (int i = 0; i < 4; i ++) { zoz[i][2] += zoz[i][1]; zoz[i][2] %= m; } } else { for (int j = 3; j > 0; j -= 2) { for (int i = 0; i < 4; i ++) { zoz[i][j] += zoz[i][j - 1]; zoz[i][j] %= m; } } } } ll ans = 0; ll n = s.size(); for (int i = 0; i <= min(hc, 3ll); i ++) { ans += (mpow(2, hc - i) * zoz[i][3]) % m; ans %= m; } ans = (ans * mpow(2, n - 3)) % m; cout << ans << endl; }