#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
char s[2000006];
long long dp[2000006][5];
int main() {
  int i, j, k, l;
  int n;
  while (cin >> s) {
    memset(dp, 0, sizeof(dp));
    int len = strlen(s);
    if (s[0] == '?') {
      dp[0][0] = dp[0][3] = dp[0][4] = 1;
    } else if (s[0] == '0') {
      dp[0][0] = 1;
    } else if (s[0] == '1') {
      dp[0][4] = 1;
    } else if (s[0] == '*') {
      dp[0][3] = 1;
    } else {
      puts("0");
      continue;
    }
    for (i = 1; i < len; i++) {
      if (s[i] == '*') {
        dp[i][3] = (dp[i][3] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4]) %
                   1000000007;
      } else if (s[i] == '0') {
        dp[i][0] = (dp[i][0] + dp[i - 1][0] + dp[i - 1][1]) % 1000000007;
      } else if (s[i] == '1') {
        dp[i][1] = (dp[i][1] + dp[i - 1][3]) % 1000000007;
        dp[i][4] = (dp[i][4] + dp[i - 1][0] + dp[i - 1][1]) % 1000000007;
      } else if (s[i] == '2') {
        dp[i][2] = (dp[i][2] + dp[i - 1][3]) % 1000000007;
      } else {
        dp[i][3] = (dp[i][3] + dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4]) %
                   1000000007;
        dp[i][0] = (dp[i][0] + dp[i - 1][0] + dp[i - 1][1]) % 1000000007;
        dp[i][1] = (dp[i][1] + dp[i - 1][3]) % 1000000007;
        dp[i][4] = (dp[i][4] + dp[i - 1][0] + dp[i - 1][1]) % 1000000007;
        dp[i][2] = (dp[i][2] + dp[i - 1][3]) % 1000000007;
      }
    }
    long long ans =
        (dp[len - 1][0] + dp[len - 1][1] + dp[len - 1][3]) % 1000000007;
    cout << ans << endl;
  }
  return 0;
}
