#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
long long F[MAXN][5];
const int MOD = 1e9 + 7;
char c[MAXN];
int L;
int main() {
  gets(c + 1);
  L = strlen(c + 1);
  if (c[1] == '2' || c[L] == '2') {
    printf("0\n");
    return 0;
  }
  if (c[1] == '0' || c[1] == '?') F[1][0] = 1;
  if (c[1] == '1' || c[1] == '?') F[1][2] = 1;
  if (c[1] == '*' || c[1] == '?') F[1][4] = 1;
  for (int i = 2; i <= L; i++) {
    if (c[i] == '0' || c[i] == '?') F[i][0] = F[i - 1][0] + F[i - 1][1];
    if (c[i] == '1' || c[i] == '?') {
      F[i][1] = F[i - 1][4];
      F[i][2] = F[i - 1][0] + F[i - 1][1];
    }
    if (c[i] == '2' || c[i] == '?') {
      F[i][3] = F[i - 1][4];
    }
    if (c[i] == '*' || c[i] == '?') {
      F[i][4] = F[i - 1][2] + F[i - 1][3] + F[i - 1][4];
    }
    for (int ii = 0; ii < 5; ii++) F[i][ii] %= MOD;
  }
  F[L][2] = F[L][3] = 0;
  long long ans = 0;
  for (int ii = 0; ii < 5; ii++) ans += F[L][ii];
  ans %= MOD;
  printf("%d\n", (int)ans);
}
