#include #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;} mint operator+(const mint a) const { return mint(*this) += a;} mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return *this *= a.inv();} mint operator/(const mint a) const { return mint(*this) /= a;} }; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); string s; cin >> s; vector dp(3, mint(0)); dp[0] = mint(1); mint ans = mint(0); all(c, s) { if(c == '0') { dp[1] += dp[0]; ans += dp[2]; } else if(c == '1') { dp[2] += dp[1]; } else { vector nx(3, mint(0)); rep(j, 3) nx[j] += dp[j] * mint(2); ans += ans; ans += dp[2]; nx[2] += dp[1]; nx[1] += dp[0]; swap(nx, dp); } } cout <