#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=3e5+5;
const int mod=1e9+7;
int f[N][3][3],n,ans;
char s[N];
signed main(){
	scanf("%s",s+1);n=strlen(s+1);
	f[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int x=0;x<=2;x++)for(int y=0;y<=2;y++)if(f[i][x][y]){
			if(s[i+1]!='0'){
				if(y==0)f[i+1][x+(x!=2)][y]=(f[i+1][x+(x!=2)][y]+f[i][x][y])%mod;
				else f[i+1][x][y-1]=(f[i+1][x][y-1]+f[i][x][y])%mod;
			}
			if(s[i+1]!='1'){
				if(y==2)f[i+1][x][y-1]=(f[i+1][x][y-1]+f[i][x][y])%mod;
				else f[i+1][x][y+1]=(f[i+1][x][y+1]+f[i][x][y])%mod;
			}
		}
	}
	for(int x=0;x<=2;x++)for(int y=0;y<=x;y++)ans=(ans+f[n][x][y])%mod;
	return cout<<ans,signed();
}