#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10, mod = 1e9 + 7;
char str[N];
long long dp[N][5], n;
signed main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  dp[0][1] = dp[0][2] = 1;
  for (long long i = 1; i <= n; i++) {
    if (str[i] == '?') {
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][2] + dp[i - 1][4]) % mod;
      dp[i][1] = (dp[i - 1][1] + dp[i - 1][3]) % mod;
      dp[i][2] = (dp[i - 1][1] + dp[i - 1][3]) % mod;
      dp[i][3] = dp[i - 1][0];
      dp[i][4] = dp[i - 1][0];
    } else if (str[i] == '0') {
      dp[i][1] = (dp[i - 1][1] + dp[i - 1][3]) % mod;
    } else if (str[i] == '1') {
      dp[i][3] = dp[i - 1][0];
      dp[i][2] = (dp[i - 1][1] + dp[i - 1][3]) % mod;
    } else if (str[i] == '2') {
      dp[i][4] = dp[i - 1][0];
    } else if (str[i] == '*') {
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][2] + dp[i - 1][4]) % mod;
    }
  }
  cout << (dp[n][0] + dp[n][1] + dp[n][3]) % mod;
  return 0;
}
