#include <bits/stdc++.h>
using namespace std;
char s[1000004];
long long d[1000004][4][2];
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1), i, cnt = 0;
  d[0][0][0] = 1;
  d[0][0][1] = 1;
  for (i = 1; i <= n; ++i) {
    cnt += (s[i] == '?');
    if (s[i] == '0') {
      d[i][0][0] = d[i - 1][0][0] + d[i - 1][1][0];
      d[i][0][0] %= 1000000007;
    }
    if (s[i] == '1') {
      d[i][1][0] = d[i - 1][3][0];
      d[i][1][0] %= 1000000007;
      d[i][1][1] = d[i - 1][1][0] + d[i - 1][0][0];
      d[i][1][1] %= 1000000007;
    }
    if (s[i] == '2') {
      d[i][2][1] = d[i - 1][3][0];
      d[i][2][1] %= 1000000007;
    }
    if (s[i] == '*') {
      d[i][3][0] =
          d[i - 1][1][1] + d[i - 1][2][1] + d[i - 1][3][1] + d[i - 1][0][1];
      d[i][3][0] %= 1000000007;
      d[i][3][1] =
          d[i - 1][1][1] + d[i - 1][2][1] + d[i - 1][3][1] + d[i - 1][0][1];
      d[i][3][1] %= 1000000007;
    }
    if (s[i] == '?') {
      d[i][0][0] = d[i - 1][0][0] + d[i - 1][1][0];
      d[i][0][0] %= 1000000007;
      d[i][1][0] = d[i - 1][3][0];
      d[i][1][0] %= 1000000007;
      d[i][1][1] = d[i - 1][1][0] + d[i - 1][0][0];
      d[i][1][1] %= 1000000007;
      d[i][2][1] = d[i - 1][3][0];
      d[i][2][1] %= 1000000007;
      d[i][3][0] =
          d[i - 1][1][1] + d[i - 1][2][1] + d[i - 1][3][1] + d[i - 1][0][1];
      d[i][3][0] %= 1000000007;
      d[i][3][1] =
          d[i - 1][1][1] + d[i - 1][2][1] + d[i - 1][3][1] + d[i - 1][0][1];
      d[i][3][1] %= 1000000007;
    }
  }
  cout << ((d[n][0][0] + d[n][1][0]) % 1000000007 +
           (d[n][2][0] + d[n][3][0]) % 1000000007) %
              1000000007;
  return 0;
}
