#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000000000000000LL;
const double EPS = 1e-9;
const long long mod = 1000000007ll;
const int maxn = (int)1000500 + 10;
int seq[maxn];
int n, m;
int dp[1000005][5][2];
int rec(int idx, int last, bool bo) {
  if (idx == n) return (bo == 0);
  int &ret = dp[idx][last][bo];
  if (ret != -1) return ret;
  ret = 0;
  if (seq[idx] == 0) {
    if (last != 3 && (last != 1 || bo == 0) && last != 2)
      ret = rec(idx + 1, 0, 0);
  } else if (seq[idx] == 1) {
    if (last == 3)
      ret = (ret + rec(idx + 1, 1, 0)) % mod;
    else if (last != 2 && (last != 1 || bo == 0))
      ret = (ret + rec(idx + 1, 1, 1)) % mod;
  } else if (seq[idx] == 2) {
    if (last == 3) ret = (ret + rec(idx + 1, 2, 1)) % mod;
  } else if (seq[idx] == 3) {
    if (last != 0 && (last != 1 || bo == 1))
      ret = (ret + rec(idx + 1, 3, 0)) % mod;
  } else {
    if (last != 3 && (last != 1 || bo == 0) && last != 2)
      ret = rec(idx + 1, 0, 0) % mod;
    if (last == 3)
      ret = (ret + rec(idx + 1, 1, 0)) % mod;
    else if (last != 2 && (last != 1 || bo == 0))
      ret = (ret + rec(idx + 1, 1, 1)) % mod;
    if (last == 3 && idx + 1 < n) ret = (ret + rec(idx + 1, 2, 0)) % mod;
    if ((last != 1 || bo == 1) && last != 0)
      ret = (ret + rec(idx + 1, 3, 0)) % mod;
  }
  return ret;
}
int main() {
  char st[1000500];
  scanf("%s", st);
  n = strlen(st);
  for (int i = 0; i < (int)(n); ++i)
    if (st[i] == '?')
      seq[i] = 4;
    else if (st[i] == '*')
      seq[i] = 3;
    else
      seq[i] = (st[i] - '0');
  memset(dp, -1, sizeof(dp));
  printf("%d\n", rec(0, 4, 0));
}
