#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 10;
const int mod = 1e9 + 7;
char s[maxn];
int dp[maxn][5];
int main() {
  scanf("%s", s + 1);
  int l = strlen(s + 1);
  memset(dp, 0, sizeof(dp));
  if (s[1] == '0')
    dp[1][0] = 1;
  else if (s[1] == '1')
    dp[1][2] = 1;
  else if (s[1] == '*')
    dp[1][4] = 1;
  else if (s[1] == '?') {
    dp[1][0] = 1;
    dp[1][2] = 1;
    dp[1][4] = 1;
  }
  for (int i = 2; i <= l; i++) {
    if (s[i] == '*') {
      dp[i][4] = ((dp[i - 1][2] + dp[i - 1][3]) % mod + dp[i - 1][4]) % mod;
    } else if (s[i] == '0') {
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
    } else if (s[i] == '1') {
      dp[i][1] = (dp[i - 1][4]) % mod;
      dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
    } else if (s[i] == '2') {
      dp[i][3] = (dp[i - 1][4]) % mod;
    } else if (s[i] == '?') {
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
      dp[i][1] = (dp[i - 1][4]) % mod;
      dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % mod;
      dp[i][3] = (dp[i - 1][4]) % mod;
      dp[i][4] = ((dp[i - 1][2] + dp[i - 1][3]) % mod + dp[i - 1][4]) % mod;
    }
  }
  int sum = ((dp[l][0] + dp[l][1]) % mod + dp[l][4]) % mod;
  printf("%d\n", sum);
  return 0;
}
