#include <bits/stdc++.h>
const int MAXN = 1100000;
const unsigned M = 1000000000 + 7;
char s[MAXN];
int n;
unsigned dp[MAXN][5];
bool dpz[5];
int main() {
  scanf("%s", s);
  n = strlen(s);
  if (s[0] == '2') {
    printf("0");
    return 0;
  }
  if (n == 1) {
    if (s[0] == '?') printf("2");
    if (s[0] == '*') printf("1");
    if (s[0] == '0') printf("1");
    if (s[0] == '1') printf("0");
    return 0;
  }
  for (int j = 0; j < 5; j++) {
    dp[0][j] = 0;
  }
  if (s[0] == '?') {
    dp[0][0] = 1;
    dp[0][1] = 1;
    dp[0][4] = 1;
  } else {
    if (s[0] == '0') dp[0][0] = 1;
    if (s[0] == '1') dp[0][1] = 1;
    if (s[0] == '*') dp[0][4] = 1;
  }
  for (int i = 1; i < n; i++) {
    dp[i][0] = (dp[i - 1][0] + dp[i - 1][2]) % M;
    dp[i][1] = dp[i][0];
    dp[i][2] = dp[i - 1][4];
    dp[i][3] = dp[i][2];
    dp[i][4] = (dp[i - 1][1] + dp[i - 1][3] + dp[i - 1][4]) % M;
    if (s[i] == '?') continue;
    for (int j = 0; j < 5; j++) {
      dpz[j] = true;
    }
    if (s[i] == '0') dpz[0] = false;
    if (s[i] == '1' && s[i - 1] != '*') dpz[1] = false;
    if (s[i] == '1' && (s[i - 1] == '*' || s[i - 1] == '?')) dpz[2] = false;
    if (s[i] == '2') dpz[3] = false;
    if (s[i] == '*') dpz[4] = false;
    for (int j = 0; j < 5; j++) {
      if (dpz[j]) dp[i][j] = 0;
    }
  }
  unsigned a = ((dp[n - 1][0] + dp[n - 1][2]) % M + dp[n - 1][4]) % M;
  printf("%d", a);
}
