#include <bits/stdc++.h>
using namespace std;
int i, l, ans, dp[1001000][5];
char s[1001000];
void f(int &a, int b) { a = (a + b) % 1000000007; }
int main() {
  scanf("%s", s + 1);
  l = strlen(s + 1);
  dp[0][0] = dp[0][1] = 1;
  for (i = 1; i <= l; i++) {
    if (s[i] == '?' || s[i] == '0') {
      f(dp[i][0], dp[i - 1][2]);
      f(dp[i][0], dp[i - 1][0]);
    }
    if (s[i] == '?' || s[i] == '1') {
      f(dp[i][2], dp[i - 1][4]);
      f(dp[i][1], dp[i - 1][0]);
      f(dp[i][1], dp[i - 1][2]);
    }
    if (s[i] == '?' || s[i] == '2') f(dp[i][3], dp[i - 1][4]);
    if (s[i] == '?' || s[i] == '*') {
      f(dp[i][4], dp[i - 1][3]);
      f(dp[i][4], dp[i - 1][1]);
      f(dp[i][4], dp[i - 1][4]);
    }
  }
  ans = 0;
  if (s[l] == '?' || s[l] == '0') f(ans, dp[l][0]);
  if (s[l] == '?' || s[l] == '1') f(ans, dp[l][2]);
  if (s[l] == '?' || s[l] == '*') f(ans, dp[l][4]);
  printf("%d", ans);
  return 0;
}
