#include <bits/stdc++.h>
using namespace std;
string s;
int n;
char z[1001000];
long long dp[1001000][5];
long long md = 1000LL * 1000 * 1000 + 7;
long long state(int i, int pr) {
  if (i == n) {
    if (pr == 3 || pr == 2) return 0;
    return 1;
  }
  if (dp[i][pr] != -1) return dp[i][pr];
  if (pr == 0) {
    if (s[i] == '2') return dp[i][pr] = 0;
    if (s[i] == '1') return dp[i][pr] = state(i + 1, 2);
    if (s[i] == '*') return dp[i][pr] = state(i + 1, 4);
    if (s[i] == '0') return dp[i][pr] = state(i + 1, 1);
    if (s[i] == '?') {
      long long ans = 0;
      ans += state(i + 1, 4);
      ans %= md;
      ans += state(i + 1, 1);
      ans %= md;
      ans += state(i + 1, 2);
      ans %= md;
      return dp[i][pr] = ans;
    }
  }
  if (pr == 1) {
    if (s[i] == '*' || s[i] == '2') return dp[i][pr] = 0;
    if (s[i] == '?') {
      long long ans = 0;
      ans += state(i + 1, 2);
      ans %= md;
      ans += state(i + 1, 1);
      ans %= md;
      return dp[i][pr] = ans;
    }
    if (s[i] == '0') return dp[i][pr] = state(i + 1, 1);
    if (s[i] == '1') return dp[i][pr] = state(i + 1, 2);
  }
  if (pr == 2) {
    if (s[i] == '*' || s[i] == '?') return dp[i][pr] = state(i + 1, 4);
    return dp[i][pr] = 0;
  }
  if (pr == 4) {
    if (s[i] == '0') return dp[i][pr] = 0;
    if (s[i] == '1') return dp[i][pr] = state(i + 1, 1);
    if (s[i] == '2') return dp[i][pr] = state(i + 1, 2);
    if (s[i] == '?') {
      long long ans = 0;
      ans += state(i + 1, 2);
      ans %= md;
      ans += state(i + 1, 1);
      ans %= md;
      ans += state(i + 1, 4);
      ans %= md;
      return dp[i][pr] = ans;
    }
    if (s[i] == '*') return dp[i][pr] = state(i + 1, 4);
  }
}
int main() {
  scanf("%s", z);
  s = string(z);
  n = s.size();
  memset(dp, -1, sizeof dp);
  cout << state(0, 0) << '\n';
  return 0;
}
