#include #include #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repll(i, n) for (long long i = 0; i < (long long)(n); i++) #define rep2(i, n, m) for (int i = n; i < (int)(m); i++) #define repll2(i, n, m) for (long long i = n; i < (long long)(m); i++) #define all(v) v.begin(),v.end() using ll=long long; using ld=long double; using vi=vector; using vvi=vector; using vvvi=vector; using vl=vector; using vvl=vector; using vvvl=vector; using vld=vector; using vvld=vector; int dx[8]={1,0,-1,0,1,1,-1,-1}; int dy[8]={0,1,0,-1,1,-1,1,-1}; const double PI = acos(-1); //const ll MOD=1e9+7; //const ll MOD=998244353; const ll INF=(1LL<<60); const int INF2=(1<<30); //using mint=modint1000000007; using mint=modint998244353; int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); string s;cin>>s; int sz=s.size(); vl cnt_0(sz+1,0),cnt_1(sz+1,1),cnt_q(sz+1,0); rep(i,sz){ cnt_0[i+1]=cnt_0[i]; cnt_1[i+1]=cnt_1[i]; cnt_q[i+1]=cnt_q[i]; if(s[i]=='0')cnt_0[i+1]++; else if(s[i]=='1')cnt_1[i+1]++; else cnt_q[i+1]++; } mint ans=0; ll cnt_q_all=cnt_q[sz]; rep(i,sz){ if(s[i]=='0')continue; else if(s[i]=='1'){ //010,?10,01?,?0? ll cnt_0_l=cnt_0[i],cnt_0_r=cnt_0[sz]-cnt_0[i+1]; ll cnt_q_l=cnt_q[i],cnt_q_r=cnt_q[sz]-cnt_q[i+1]; ans+=cnt_0_l*cnt_0_r*mint(2).pow(cnt_q[sz]); //010 if(cnt_q_all>0){ ans+=cnt_q_l*cnt_0_r*mint(2).pow(cnt_q[sz]-1); //?10 ans+=cnt_0_l*cnt_q_r*mint(2).pow(cnt_q[sz]-1); //01? } if(cnt_q_all>1){ ans+=cnt_q_l*cnt_q_r*mint(2).pow(cnt_q[sz]-2); //?1? } } else{ //0?0,??0,0??,??? ll cnt_0_l=cnt_0[i],cnt_0_r=cnt_0[sz]-cnt_0[i+1]; ll cnt_q_l=cnt_q[i],cnt_q_r=cnt_q[sz]-cnt_q[i+1]; if(cnt_q_all>0)ans+=cnt_0_l*cnt_0_r*mint(2).pow(cnt_q[sz]-1); //0?0 if(cnt_q_all>1)ans+=cnt_q_l*cnt_0_r*mint(2).pow(cnt_q[sz]-2); //??0 if(cnt_q_all>1)ans+=cnt_0_l*cnt_q_r*mint(2).pow(cnt_q[sz]-2); //0?? if(cnt_q_all>2)ans+=cnt_q_l*cnt_q_r*mint(2).pow(cnt_q[sz]-3); //??? } } cout<