#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long dp[1000010][5];
bool vis[1000010][5];
int n;
char in[1000010];
long long ad(long long a, long long b) { return (a + b) % mod; }
long long get(int pos, int last) {
  if (pos == n) {
    if (last == 0) return 1;
    if (last == 1) return 1;
    if (last == 2) return 0;
    if (last == 3) return 0;
    if (last == 4) return 1;
  }
  if (vis[pos][last]) return dp[pos][last];
  long long ret = 0;
  if (last == 0 || last == 1) {
    if (in[pos] == '?') {
      ret = ad(get(pos + 1, 2), ret);
      ret = ad(get(pos + 1, 0), ret);
    } else {
      if (in[pos] == '1')
        ret = ad(get(pos + 1, 2), ret);
      else if (in[pos] == '0')
        ret = ad(get(pos + 1, 0), ret);
    }
  } else if (last == 2 || last == 3) {
    if (in[pos] == '?') {
      ret = ad(get(pos + 1, 4), ret);
    } else {
      if (in[pos] == '*') ret = ad(get(pos + 1, 4), ret);
    }
  } else if (last == 4) {
    if (in[pos] == '?') {
      ret = ad(get(pos + 1, 1), ret);
      ret = ad(get(pos + 1, 3), ret);
      ret = ad(get(pos + 1, 4), ret);
    } else {
      if (in[pos] == '1')
        ret = ad(get(pos + 1, 1), ret);
      else if (in[pos] == '2')
        ret = ad(get(pos + 1, 3), ret);
      else if (in[pos] == '*')
        ret = ad(get(pos + 1, 4), ret);
    }
  }
  vis[pos][last] = 1;
  dp[pos][last] = ret;
  return ret;
}
int main() {
  int i, j;
  mod = 1000000007;
  scanf("%s", in);
  n = strlen(in);
  for (i = n - 1; i >= 0; i--)
    for (j = 0; j < 5; j++) get(i, j);
  int ret = 0;
  if (in[0] == '?') {
    ret = ad(ret, get(1, 0));
    ret = ad(ret, get(1, 2));
    ret = ad(ret, get(1, 4));
  } else {
    if (in[0] == '0') ret = ad(ret, get(1, 0));
    if (in[0] == '1') ret = ad(ret, get(1, 2));
    if (in[0] == '*') ret = ad(ret, get(1, 4));
  }
  printf("%d\n", ret);
  return 0;
}
