#include <bits/stdc++.h>

// #define DEBUG 1

//#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 300000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

ll dp[MAXN+5][4][3];

pair<int,int> get_next_state(int s, int x, bool bit) 
{
    // State 0: current pattern ends with "11"
    // State 1: current pattern ends with "110"
    // State 2: current pattern ends with "1100"
    // State 3: current pattern ends with "11001"
    // x = number of times we've done the 0 -> 0 transition
    if (s == 0) {
        if (bit == 0)
            return {1,x};
        else 
            return {0,min(2,x+1)};
    }
    else if (s == 1) {
        if (bit == 0)
            return {2,x};
        else 
            return {0,x};
    }
    else if (s == 2) {
        if (bit == 0)
            return {1,x};
        else 
            return {3,x};
    }
    else if (s == 3) {
        if (bit == 0)
            return {2,x};
        else 
            return {0,x};
    }    
}

long long mod_pow(long long b, long long e, long long mod)
{
    long long r = 1, q = b;
    while (e){
        if (e&1) r = (r*q) % mod;
        q = (q*q) % mod;
        e >>= 1;
    }
    return r;
}

int32_t main()
{
    #ifdef DEBUG
    //freopen("A.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    string pattern;
    cin >> pattern;
    int n = pattern.length();
    
    // dp counts number of losing patterns 
    ms(dp,0);
    dp[n][2][0] = dp[n][2][1] = 1;
    dp[n][3][0] = dp[n][1][0] = 1;
    
    for (int i=n-1; i>=0; i--) {
        for (int s=0; s<=3; s++) {
            for (int x=0; x<=2; x++) {
                int nexts,nextx;
                
                if (pattern[i] == '?') {
                    tie(nexts,nextx) = get_next_state(s,x,0);
                    dp[i][s][x] += dp[i+1][nexts][nextx]; 
                    tie(nexts,nextx) = get_next_state(s,x,1);
                    dp[i][s][x] += dp[i+1][nexts][nextx]; 
                    dp[i][s][x] %= MOD; 
                }
                else {
                    bool bit = pattern[i]-'0';
                    tie(nexts,nextx) = get_next_state(s,x,bit);
                    dp[i][s][x] += dp[i+1][nexts][nextx];    
                }                
            }
        }
    }
    
    int cnt = 0;
    for0(i,n)
        cnt += pattern[i] == '?';
    ll tot = mod_pow(2,cnt,MOD);
    prl(tot)
    
    ll bad = dp[0][0][0];
    prl(bad)
    ll good = pmod(tot-bad, MOD);
    cout<<good<<endl;
    return 0;
}


Measured memory_bytes: 28804