#include <bits/stdc++.h>
long long mod = 1000000007;
using namespace std;
int n;
char a[1000005];
char ch[5] = {'?', '*', '0', '1', '2'};
long long dp[1000005][6];
long long func(int i, int prev) {
  long long ans = 0;
  if (i == n) {
    if (prev == 1 || prev == 2 || prev == 3)
      ans = 1;
    else
      ans = 0;
    return ans;
  }
  if (i == 0) {
    if (a[i] == '2') ans = 0;
    if (a[i] == '*') ans = func(i + 1, 1);
    if (a[i] == '0') ans = func(i + 1, 2);
    if (a[i] == '1') ans = func(i + 1, 5);
    if (a[i] == '?') ans = func(i + 1, 2) + func(i + 1, 5) + func(i + 1, 1);
    return ans;
  }
  if (dp[i][prev] != -1) {
    ans = dp[i][prev];
    return ans;
  }
  if (prev == 2) {
    if (a[i] == '*' || a[i] == '2') ans = dp[i][prev] = 0;
    if (a[i] == '0') ans = dp[i][prev] = func(i + 1, 2);
    if (a[i] == '1') ans = func(i + 1, 5);
    if (a[i] == '?') ans = func(i + 1, 2) + func(i + 1, 5);
  }
  if (prev == 1) {
    if (a[i] == '2') ans = func(i + 1, 4);
    if (a[i] == '*') ans = func(i + 1, 1);
    if (a[i] == '0') ans = 0;
    if (a[i] == '1') ans = func(i + 1, 3);
    if (a[i] == '?') ans = func(i + 1, 3) + func(i + 1, 4) + func(i + 1, 1);
  }
  if (prev == 3) {
    if (a[i] == '2') ans = 0;
    if (a[i] == '*') ans = 0;
    if (a[i] == '0') ans = func(i + 1, 2);
    if (a[i] == '1') ans = func(i + 1, 5);
    if (a[i] == '?') ans = func(i + 1, 2) + func(i + 1, 5);
  }
  if (prev == 4 || prev == 5) {
    if (a[i] == '2') ans = 0;
    if (a[i] == '*') ans = dp[i][prev] = func(i + 1, 1);
    if (a[i] == '0') ans = dp[i][prev] = 0;
    if (a[i] == '1') ans = dp[i][prev] = 0;
    if (a[i] == '?') ans = dp[i][prev] = func(i + 1, 1);
  }
  return dp[i][prev] = ans % mod;
}
int main() {
  int i, j, fl, test;
  scanf("%s", a);
  n = strlen(a);
  memset(dp, -1, sizeof(dp));
  printf("%lld\n", func(0, 3) % mod);
  return 0;
}
