#include <bits/stdc++.h>
using namespace std;
const int MAXN=300100,MOD=1e9+7;
const int automata[8][2]={{3,1},{5,2},{2,2},{4,7},{3,3},{6,1},{5,5},{3,1}};
char ch[MAXN];
int dp[MAXN][8],len;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>ch;
	len=strlen(ch);
	dp[len][1]=dp[len][2]=1;
	for(register int i=len-1;~i;i--)
		for(register int j=0;j<8;j++)
		{
			if(ch[i]!='0') dp[i][j]=(dp[i][j]+dp[i+1][automata[j][1]])%MOD;
			if(ch[i]!='1') dp[i][j]=(dp[i][j]+dp[i+1][automata[j][0]])%MOD;
		}
	cout<<dp[0][0]<<endl;
	return 0;
}
#include <cstdio>
#include <cstring>

using namespace std;

char s[300001];
long long b[300001];
int c[300001];
long long dp[2][3];

bool can(int x, int c) {
    return (s[x] == '?') || (s[x] == '0' + c);
}

int main() {
    int n, m = 1000000007, i, j, k, l;
    long long ans = 0;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    b[0] = 1;
    for (i = 1; i <= n; i++) b[i] = b[i - 1] * 2 % m;
    
    for (i = n - 1; i >= 0; i--) {
        c[i] = c[i + 1];
        if (s[i] == '?') c[i]++;
    }
    
    for (i = 0; i < 2; i++) {
        if (can(0, i)) dp[0][i]++;
    }
    
    for (i = 1; i < n; i += 2) {
        for (j = 0; j < 2; j++) {
            for (k = 0; k < 2; k++) {
                if (!can(i, j) || !can(i + 1, k)) continue;
                
                for (l = 0; l < 3; l++) {
                    long long x = dp[0][l];
                    
                    if (x == 0) continue;
                    
                    if (l == 0) {
                        if (j == 1 && k == 1) {
                            dp[1][1] += x;
                            if (dp[1][1] >= m) dp[1][1] -= m;
                        } else {
                            dp[1][0] += x;
                            if (dp[1][0] >= m) dp[1][0] -= m;
                        }
                    } else if (l == 1) {
                        if (j == 1) {
                            ans += x * b[c[i + 2]] % m;
                            if (ans >= m) ans -= m;
                        } else if (j == 0 && k == 0) {
                            dp[1][2] += x;
                            if (dp[1][2] >= m) dp[1][2] -= m;
                        } else {
                            dp[1][1] += x;
                            if (dp[1][1] >= m) dp[1][1] -= m;
                        }
                    } else {
                        if (k == 0) {
                            dp[1][2] += x;
                            if (dp[1][2] >= m) dp[1][2] -= m;
                        } else {
                            dp[1][1] += x;
                            if (dp[1][1] >= m) dp[1][1] -= m;
                        }
                    }
                }
            }
        }
        
        for (j = 0; j < 3; j++) {
            dp[0][j] = dp[1][j];
            dp[1][j] = 0;
        }
    }
    
    printf("%lld\n", (ans + dp[0][1]) % m);
    
    return 0;
}
