#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const double EPS = 1E-5;
const int INF = 2 * (1e+9) + 1;
const int NMAX = 32000;
const int MOD = (1e+9) + 7;
int n;
string s;
long long dp[1000100][5];
int main() {
  cin >> s;
  int n = (long long)(s).size();
  if (s[0] == '0')
    dp[0][0] = 1;
  else if (s[0] == '1')
    dp[0][2] = 1;
  else if (s[0] == '2')
    dp[0][3] = 0;
  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 <= (n - 1); ++i) {
    if (s[i] == '0')
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
    else if (s[i] == '1') {
      dp[i][1] = (dp[i - 1][4]) % MOD;
      dp[i][2] = (dp[i - 1][1] + dp[i - 1][0]) % MOD;
    } else if (s[i] == '2')
      dp[i][3] = (dp[i - 1][4]) % MOD;
    else if (s[i] == '*')
      dp[i][4] = (dp[i - 1][3] + dp[i - 1][2] + dp[i - 1][4]) % MOD;
    else if (s[i] == '?') {
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
      dp[i][1] = (dp[i - 1][4]) % MOD;
      dp[i][2] = (dp[i - 1][1] + dp[i - 1][0]) % MOD;
      dp[i][3] = (dp[i - 1][4]) % MOD;
      dp[i][4] = (dp[i - 1][3] + dp[i - 1][2] + dp[i - 1][4]) % MOD;
    }
  }
  cout << ((dp[n - 1][0] + dp[n - 1][1] + dp[n - 1][4]) % MOD);
}
