#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, N = 1e6 + 6;
long long dp[N][5];
int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (s[0] == '0')
    dp[0][0] = 1;
  else if (s[0] == '1')
    dp[0][2] = 1;
  else if (s[0] == '*')
    dp[0][4] = 1;
  else if (s[0] == '?') {
    dp[0][0] = dp[0][2] = dp[0][4] = 1;
  }
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == '*') {
      dp[i][4] = dp[i - 1][4] + dp[i - 1][2] + dp[i - 1][3];
      dp[i][4] %= MOD;
    } else if (s[i] == '0') {
      dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
      dp[i][0] %= MOD;
    } else if (s[i] == '1') {
      dp[i][1] = dp[i - 1][4];
      dp[i][1] %= MOD;
      if (i < s.size() - 1) {
        dp[i][2] = dp[i - 1][0] + dp[i - 1][1];
        dp[i][2] %= MOD;
      }
    } else if (s[i] == '2') {
      if (i < s.size() - 1) {
        dp[i][3] = dp[i - 1][4];
        dp[i][3] %= MOD;
      }
    } else {
      dp[i][4] = dp[i - 1][4] + dp[i - 1][2] + dp[i - 1][3];
      dp[i][4] %= MOD;
      dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
      dp[i][0] %= MOD;
      dp[i][1] = dp[i - 1][4];
      dp[i][1] %= MOD;
      if (i < s.size() - 1) {
        dp[i][2] = dp[i - 1][0] + dp[i - 1][1];
        dp[i][2] %= MOD;
        dp[i][3] = dp[i - 1][4];
        dp[i][3] %= MOD;
      }
    }
  }
  cout << (dp[n - 1][4] + dp[n - 1][0] + dp[n - 1][1]) % MOD;
}
