#include <bits/stdc++.h>
using namespace std;
int n, ans = 1;
char s[1000010];
int m[1000010];
int main() {
  scanf("%s", s);
  n = strlen(s);
  if (n == 1) {
    switch (s[0]) {
      case '?':
        printf("2");
        break;
      case '0':
      case '*':
        printf("1");
        break;
      default:
        printf("0");
        break;
    }
    exit(0);
  }
  memset(m, -1, sizeof(m));
  for (int i = 0; i < n; i++)
    if (s[i] == '*')
      m[i] = 1;
    else if (isdigit(s[i]))
      m[i] = 0;
  if (s[0] == '2' || s[0] == '1' && m[1] == 0 || s[0] == '0' && m[1] == 1) {
    printf("0");
    exit(0);
  }
  if (s[n - 1] == '2' || s[n - 1] == '1' && m[n - 2] == 0 ||
      s[n - 1] == '0' && m[n - 2] == 1) {
    printf("0");
    exit(0);
  }
  if (s[0] == '1')
    m[1] = 1;
  else if (s[0] == '0')
    m[1] = 0;
  if (s[n - 1] == '1')
    m[n - 2] = 1;
  else if (s[n - 1] == '0')
    m[n - 2] = 0;
  for (int i = 1; i < n - 1; i++) {
    if (s[i] == '2' && (m[i - 1] == 0 || m[i + 1] == 0) ||
        s[i] == '0' && (m[i - 1] == 1 || m[i + 1] == 1) ||
        s[i] == '1' && (m[i - 1] == 0 && m[i + 1] == 0 ||
                        m[i - 1] == 1 && m[i + 1] == 1)) {
      printf("0");
      exit(0);
    }
    if (s[i] == '2') m[i - 1] = m[i + 1] = 1;
    if (s[i] == '0') m[i - 1] = m[i + 1] = 0;
    if (s[i] == '1') {
      if (m[i - 1] == 1)
        m[i + 1] = 0;
      else if (m[i - 1] == 0)
        m[i + 1] = 1;
    }
  }
  for (int i = n - 2; i >= 1; i--) {
    if (s[i] == '1') {
      if (m[i + 1] == 1)
        m[i - 1] = 0;
      else if (m[i + 1] == 0)
        m[i - 1] = 1;
    }
  }
  if ((m[0] != 0 && m[0] != 1) && !isdigit(s[1])) {
    ans = ans * 2 % 1000000007;
    m[0] = 2;
  }
  if ((m[n - 1] != 0 && m[n - 1] != 1) && !isdigit(s[n - 2])) {
    ans = ans * 2 % 1000000007;
    m[n - 1] = 2;
  }
  for (int i = 1; i < n - 1; i++) {
    if ((m[i] != 0 && m[i] != 1) && !isdigit(s[i - 1]) && !isdigit(s[i + 1])) {
      ans = ans * 2 % 1000000007;
      m[i] = 2;
    }
  }
  for (int i = 0; i < n; i++) {
    if (m[i] == -1) {
      m[i] = 3;
      int j;
      for (j = i + 2; j < n && s[j - 1] == '1' && m[j] == -1; j += 2) m[j] = 3;
      ans = ans * 2 % 1000000007;
    }
  }
  printf("%d", ans);
  return 0;
}
