#include <bits/stdc++.h>
long long dp[1111111][4][4];
int main(int argc, char** argv) {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  std::string S;
  std::cin >> S;
  int size = S.size();
  if (size == 1) {
    if (S[0] == '?') {
      std::cout << 2 << std::endl;
    } else if (S[0] == '0' || S[0] == '*') {
      std::cout << 1 << std::endl;
    } else if (S[0] == '1' || S[0] == '2') {
      std::cout << 0 << std::endl;
    }
    return 0;
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < size; i++) {
    char c = S[i];
    bool wildcard = c == '?';
    if (i == 0) {
      if (c == '0' || wildcard) dp[i][0][0] = 1;
      if (c == '1' || wildcard) dp[i][1][0] = 1;
      if (c == '*' || wildcard) dp[i][3][3] = 1;
    } else {
      if (c == '0' || wildcard) {
        dp[i][0][0] = (dp[i - 1][0][0] + dp[i - 1][0][1]) % 1000000007;
        dp[i][0][1] = dp[i - 1][1][3];
      }
      if (c == '1' || wildcard) {
        dp[i][1][0] = (dp[i - 1][0][0] + dp[i - 1][0][1]);
        dp[i][1][1] = dp[i - 1][1][3];
        dp[i][1][3] =
            (dp[i - 1][3][1] + dp[i - 1][3][2] + dp[i - 1][3][3]) % 1000000007;
      }
      if (c == '2' || wildcard)
        dp[i][2][3] =
            (dp[i - 1][3][1] + dp[i - 1][3][2] + dp[i - 1][3][3]) % 1000000007;
      if (c == '*' || wildcard) {
        dp[i][3][1] = (dp[i - 1][1][0] + dp[i - 1][1][1]) % 1000000007;
        dp[i][3][2] = dp[i - 1][2][3];
        dp[i][3][3] =
            (dp[i - 1][3][1] + dp[i - 1][3][2] + dp[i - 1][3][3]) % 1000000007;
      }
    }
  }
  long long s = 0;
  for (int j = 0; j < 4; j++)
    if (j != 2)
      for (int k = 0; k < 4; k++) {
        if (j == 1 && k == 0) continue;
        if (j == 1 && k == 0) continue;
        if (j == 1 && k == 1) continue;
        s += dp[size - 1][j][k];
      }
  std::cout << s % 1000000007 << std::endl;
  return 0;
}
