#include <bits/stdc++.h>
using namespace std;
const int MAXN = INT_MAX;
const int INF = 1000000007;
const int MINN = INT_MIN;
char s[1111111];
long long dp[1111111][5];
int main() {
  int i, j, k, r, x, y, z, n, flag, l;
  int I, J, K, M, N, A, B, X, Y, L, R, T, P, G;
  gets(s);
  l = strlen(s);
  if (s[0] == '?') {
    dp[0][0] = 1;
    dp[0][1] = 1;
    dp[0][2] = 1;
  } else {
    if (s[0] == '0') {
      dp[0][0] = 1;
    } else if (s[0] == '1') {
      dp[0][1] = 1;
    } else if (s[0] == '*') {
      dp[0][2] = 1;
    }
  }
  for (i = 1; i < l; i++) {
    if (s[i] == '?') {
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][3]) % INF;
      dp[i][1] = (dp[i - 1][0] + dp[i - 1][3]) % INF;
      dp[i][3] = dp[i - 1][2];
      dp[i][4] = dp[i - 1][2];
      dp[i][2] = (dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][4]) % INF;
    } else if (s[i] == '0') {
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][3]) % INF;
    } else if (s[i] == '1') {
      dp[i][1] = (dp[i - 1][0] + dp[i - 1][3]) % INF;
      dp[i][3] = dp[i - 1][2];
    } else if (s[i] == '2') {
      dp[i][4] = dp[i - 1][2];
    } else {
      dp[i][2] = (dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][4]) % INF;
    }
  }
  int sum = (dp[l - 1][0] + dp[l - 1][2] + dp[l - 1][3]) % INF;
  printf("%d\n", sum);
  return 0;
}
