#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 1000010;
long long dp[N][4];
string s;
int main() {
  while (cin >> s) {
    int n = s.length();
    memset(dp, 0, sizeof(dp));
    dp[0][0] = dp[0][1] = 1;
    for (int i = 1; i <= n - 1; i++) {
      int sIndex = i - 1;
      char c = s[sIndex];
      if (c == '0') {
        dp[i][0] = dp[i - 1][0];
      } else if (c == '1') {
        dp[i][0] = dp[i - 1][2];
        dp[i][1] = dp[i - 1][0];
      } else if (c == '2') {
        dp[i][1] = dp[i - 1][2];
      } else if (c == '*') {
        dp[i][2] = (dp[i - 1][1] + dp[i - 1][3]) % MOD;
        dp[i][3] = (dp[i - 1][1] + dp[i - 1][3]) % MOD;
      } else {
        dp[i][0] = (dp[i - 1][0] + dp[i - 1][2]) % MOD;
        dp[i][1] = (dp[i - 1][0] + dp[i - 1][2]) % MOD;
        dp[i][2] = (dp[i - 1][1] + dp[i - 1][3]) % MOD;
        dp[i][3] = (dp[i - 1][1] + dp[i - 1][3]) % MOD;
      }
    }
    long long ans = 0;
    char c = s[n - 1];
    if (c == '0')
      ans = dp[n - 1][0];
    else if (c == '1')
      ans = dp[n - 1][2];
    else if (c == '2')
      ans = 0;
    else if (c == '*')
      ans = (dp[n - 1][1] + dp[n - 1][3]) % MOD;
    else
      ans = (dp[n - 1][0] + dp[n - 1][1] + dp[n - 1][2] + dp[n - 1][3]) % MOD;
    cout << ans << endl;
  }
  return 0;
}
