#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b 0){ if(x & 1) res = (res * a) % mod; a = (a * a) % mod; x >>= 1; } return res; } int main(){ string S; cin >> S; int N = sz(S); vector Z(N+1,0); rep(i,N) Z[i+1] = Z[i] + (S[i]=='0'); vector Q(N+1,0); rep(i,N) Q[i+1] = Q[i] + (S[i]=='?'); ll ans = 0; rep(i,N){ if(S[i]!='0'){ ll lz = Z[i]; ll rz = Z[N]-Z[i+1]; ll lq = Q[i]; ll rq = Q[N]-Q[i+1]; ll ad = 0; ad += lz*rz%mod*mpow(2,Q[N]-(S[i]=='?'))%mod; ad += lq*rz%mod*mpow(2,Q[N]-(S[i]=='?')-1)%mod; ad += lz*rq%mod*mpow(2,Q[N]-(S[i]=='?')-1)%mod; ad += lq*rq%mod*mpow(2,Q[N]-(S[i]=='?')-2)%mod; ans += ad % mod; } } cout << ans%mod << endl; return 0; }