// #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define For(i, a, b) for (int i = (int)(a); (i) < (int)(b); ++(i)) #define rFor(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); --(i)) #define rep(i, n) For(i, 0, n) #define rrep(i, n) rFor(i, n, 0) #define fi first #define se second #include #include #include #include namespace rklib { template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template bool chmin_non_negative(T &a, const T &b) { if (a < 0 || a > b) { a = b; return true; } return false; } template T div_floor(T a, T b) { if (b < 0) a *= -1, b *= -1; return a >= 0 ? a / b : (a + 1) / b - 1; } template T div_ceil(T a, T b) { if (b < 0) a *= -1, b *= -1; return a > 0 ? (a - 1) / b + 1 : a / b; } } // namespace rklib using namespace std; using namespace rklib; using lint = long long; using pii = pair; using pll = pair; using mint = atcoder::modint; int main() { string s; cin >> s; int n = s.size(); mint sum[n + 1]; rep(i, n) { if (s[i] == '0') { sum[i + 1] = 1; } else if (s[i] == '?') { sum[i + 1] = mint(2).inv(); } sum[i + 1] += sum[i]; } mint ans = 0; rep(i, n) { if (s[i] == '1') { ans += sum[i] * (sum[n] - sum[i + 1]); } else if (s[i] == '?') { ans += sum[i] * (sum[n] - sum[i + 1]) * mint(2).inv(); } } ans *= mint(2).pow(count(s.begin(), s.end(), '?')); printf("%u\n", ans.val()); }