#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char c[301000];int dp[301000][3][3],hj[301000],mi[301000],mod=1e9+7;
int main()
{
	scanf("%s",c);dp[0][0][0]=1;int n=strlen(c);
	mi[0]=1;for(int i=1;i<=n;i++)mi[i]=(mi[i-1]*2)%mod;
	for(int i=n;i>=1;i--)if(c[i-1]=='?')hj[i]=hj[i+1]+1;else hj[i]=hj[i+1];
	long long ans=0;
	for(int i=1;i<=n;i++)
	for(int x=0;x<=2;x++)
	for(int y=0;y<=2;y++)
	{
		if(c[i-1]=='1')
		{
			if(y==0)
				if(x+1>=3)ans=(ans+(long long)dp[i-1][x][y]*(long long)mi[hj[i+1]])%mod;
				else dp[i][x+1][y]=(dp[i][x+1][y]+dp[i-1][x][y])%mod;
			else dp[i][x][y-1]=(dp[i][x][y-1]+dp[i-1][x][y])%mod;
		}
		if(c[i-1]=='0')
		{
			if(y==2)dp[i][x][1]=(dp[i][x][1]+dp[i-1][x][y])%mod;
			else dp[i][x][y+1]=(dp[i][x][y+1]+dp[i-1][x][y])%mod;
		}
		if(c[i-1]=='?')
		{
			if(y==0)
				if(x+1>=3)ans=(ans+(long long)dp[i-1][x][y]*(long long)mi[hj[i+1]])%mod;
				else dp[i][x+1][y]=(dp[i][x+1][y]+dp[i-1][x][y])%mod;
			else dp[i][x][y-1]=(dp[i][x][y-1]+dp[i-1][x][y])%mod;
			if(y==2)dp[i][x][1]=(dp[i][x][1]+dp[i-1][x][y])%mod;
			else dp[i][x][y+1]=(dp[i][x][y+1]+dp[i-1][x][y])%mod;
		}
	}
	for(int y=0;y<=2;y++)for(int x=y+1;x<=2;x++)ans=(ans+dp[n][x][y])%mod;
	printf("%lld",ans);return 0;
}//01(010,001)可消 000消 dp[i][x][y]表示前i个数，1数量x，0数量y 方案数 
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const int Q = 1e9 + 7;


inline void add(int &A , int B) {
    A += B;
    if (A >= Q) A -= Q;
}


map< pair<vector<bool>,bool> , int> h[2];

char str[N];

int main() {
    cin >> str;
    int cur = 0 , nxt = 1;
    h[cur][make_pair(vector<bool>(), false)] = 1;

    for (int i = 0 ; str[i] ; ++ i) {
        h[nxt].clear();
        int L = str[i] - '0' , R = str[i] - '0';
        if (str[i] == '?') L = 0 , R = 1;
        // cout << L << ' ' << R << endl;
        for (auto it : h[cur]) {
            //int s = it.first.first.size() + 1;
            for (int j = L ; j <= R ; ++ j) {
                vector<bool> p = it.first.first;
                p.emplace_back(j);
                int s = p.size();
                if (s >= 3 && !(p[s - 3] == 1 && p[s - 2] == 0 && j == 0)) {
                    int q = j + p[s - 3] + p[s - 2];
                    p.pop_back();
                    p.pop_back();
                    p.pop_back();
                    p.push_back(q >= 2);
                    s -= 2;
                }
                add(h[nxt][make_pair(p , it.first.second || (s > 1 && p[0] == 1 && p[1] == 1))] , it.second);
            }
        }
        swap(cur , nxt);
    }
    int res = 0;
    for (auto &it : h[cur]) {

        /*vector<bool> p = it.first.first;
        for (int i = 0 ; i < p.size() ; ++ i) {
            cout << p[i] << ' ';
            } cout << "|  " << it.first.second << ' ' << it.second << endl;*/


        if (it.first.second || it.first.first.size() == 1 && it.first.first[0]) {
            add(res , it.second);
        }
    }
    cout << res << endl;
}
