#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

char __buffer[100000];

#ifdef _DEBUG
#define LOCAL
#endif

void err(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);
	
	fprintf(stderr, "\t%s", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);
	
	fprintf(stderr, "\t%s\n", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln() {
#ifdef LOCAL	
	fprintf(stderr, "\n");
#endif	
}

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 300 * 1000 + 41;
const int MOD = 1000 * 1000 * 1000 + 7;

int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int n;
char s[MAX];

int d[MAX][3][3][(1 << 2)];

int qbit(int m) {
	return __builtin_popcount(m);
}

void solve() {
	d[1][0][0][0] = 1;

	fi(1, n) {
		for (int q = 0; q <= 2; q++) {
			for (int l = 0; l <= 2; l++) {
				for (int mask = 0; mask < (1 << 2); mask++) {
					if (!d[i][q][l][mask]) continue;
					fo(0, 1) {
						if (s[i] == '?' || s[i] - '0' == o) {
							if (q == 2) {
								ass(l == 0 && mask == 0);
								d[i + 1][2][0][0] = add(d[i + 1][2][0][0], d[i][2][0][0]);
								continue;
							}
							if (l == 2) {
								int q2 = q;
								int l2 = 1;
								int tmp = mask * 2 + o;
								int mask2;
								if (qbit(tmp) == 2) {									
									mask2 = 0;
									l2 = 0;
									q2++;
								} else {
									mask2 = 0;
								}								
								d[i + 1][q2][l2][mask2] = add(d[i + 1][q2][l2][mask2], d[i][q][l][mask]);
							} else if (l == 1) {									
									int q2 = q;
									int l2 = l + 1;
									int mask2 = mask * 2 + o;
									d[i + 1][q2][l2][mask2] = add(d[i + 1][q2][l2][mask2], d[i][q][l][mask]);								
							} else if (l == 0) {
								int q2;
								int l2;
								int mask2;
								if (o == 0) {
								  q2 = q;
								  l2 = l + 1;
								  mask2 = mask * 2;
								} else {
									q2 = q + 1;
									l2 = l;
									mask2 = mask;
								}
								d[i + 1][q2][l2][mask2] = add(d[i + 1][q2][l2][mask2], d[i][q][l][mask]);									
							}
						}
					}
				}
			}
		}		
	}

	int ans = 0;
	ans = add(ans, d[n + 1][2][0][0]);	
	ans = add(ans, d[n + 1][1][0][0]);
	fo(0, 3) {
		int mask2 = o * 2 + 1;
		if (qbit(mask2) == 2) {
			ans = add(ans, d[n + 1][1][2][o]);
		}
	}	
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif


	scanf("%s", s + 1);
	n = strlen(s + 1);	
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 42752