#include <bits/stdc++.h>
using namespace std;
long long dp[1000010][5];
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  bool f = false;
  int n = s.length();
  if (s[0] == '0')
    if (s[1] != '*')
      dp[0][0] = 1;
    else
      f = true;
  else if (s[0] == '1')
    if (s[1] == '*' || s[1] == '?')
      dp[0][2] = 1;
    else
      f = true;
  else if (s[0] == '*')
    if (s[1] != '0')
      dp[0][4] = 1;
    else
      f = true;
  else if (s[0] == '2')
    f = true;
  else if (s[0] == '?') {
    dp[0][0] = (s[1] != '*');
    dp[0][2] = (s[1] == '*' || s[1] == '?');
    dp[0][4] = (s[1] != '0');
  }
  for (int i = 1; i < n; i++) {
    if (s[i] == '0') {
      dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
      dp[i][0] %= 1000000007;
    } else if (s[i] == '1') {
      dp[i][1] = dp[i - 1][4];
      dp[i][2] = dp[i - 1][0] + dp[i - 1][1];
    } else if (s[i] == '2')
      dp[i][3] += dp[i - 1][4];
    else if (s[i] == '*') {
      dp[i][4] = dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4];
      dp[i][4] %= 1000000007;
    } else if (s[i] == '?') {
      dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
      dp[i][0] %= 1000000007;
      dp[i][1] = dp[i - 1][4];
      dp[i][2] = dp[i - 1][0] + dp[i - 1][1];
      dp[i][3] += dp[i - 1][4];
      dp[i][4] = dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4];
      dp[i][4] %= 1000000007;
    }
    int check = 0;
    for (int j = 0; j < 5; j++) check += dp[i][j];
    if (!check) f = true;
  }
  if (f)
    cout << 0 << endl;
  else if (n == 1)
    cout << 1 + (s[0] == '?') << endl;
  else
    cout << (1LL * dp[n - 1][0] + dp[n - 1][1] + dp[n - 1][4]) % 1000000007
         << endl;
  return 0;
}
