#include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} const ll MOD=998244353; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin>>s; int n=s.size(); vectorP(n+1); P[0]=1; rep(i,n)P[i+1]=2*P[i]%MOD; vectorX(n+1),Y(n+1); rep(i,n){ X[i+1]=X[i]; Y[i+1]=Y[i]; if(s[i]=='0')X[i+1]++; if(s[i]=='?')Y[i+1]++; } ll ans=0; rep(i,n){ ll xl=X[i],xr=X[n]-X[i]; ll yl=Y[i],yr=Y[n]-Y[i]; if(s[i]=='?')yr--; if(s[i]!='0'){ ll c=1; c*=(xl*P[yl]+yl*(yl==0?0:P[yl-1]))%MOD; c%=MOD; c*=(xr*P[yr]+yr*(yr==0?0:P[yr-1]))%MOD; c%=MOD; ans+=c; ans%=MOD; } } cout<