#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
const int MN = 2e6 + 7;
const int Mo = 1e9 + 7;
int n, m;
char a[MN];
long long f[MN][5];
int idx(char c) {
  switch (c) {
    case '0':
    case '1':
    case '2':
      return c - '0';
    case '*':
      return 3;
  }
}
int main() {
  scanf("%s", a);
  n = strlen(a);
  if (a[0] == '?') f[0][0] = f[0][1] = f[0][3] = 1;
  if (a[0] != '?') f[0][idx(a[0])] = 1;
  f[0][2] = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == '?') {
      f[i][0] = (f[i - 1][0] + f[i - 1][4]) % Mo;
      f[i][1] = (f[i - 1][0] + f[i - 1][4]) % Mo;
      f[i][4] = f[i - 1][3] % Mo;
      f[i][2] = f[i - 1][3] % Mo;
      f[i][3] = (f[i - 1][1] + f[i - 1][2] + f[i - 1][3]) % Mo;
    }
    if (a[i] == '0') f[i][0] = (f[i - 1][0] + f[i - 1][4]) % Mo;
    if (a[i] == '1') {
      f[i][1] = (f[i - 1][0] + f[i - 1][4]) % Mo;
      f[i][4] = f[i - 1][3] % Mo;
    }
    if (a[i] == '2') f[i][2] = f[i - 1][3] % Mo;
    if (a[i] == '*') f[i][3] = (f[i - 1][1] + f[i - 1][2] + f[i - 1][3]) % Mo;
  }
  long long ans = (f[n - 1][0] + f[n - 1][3] + f[n - 1][4]) % Mo;
  cout << ans << endl;
  return 0;
}
