#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 1000000 + 6;
const int mod = 1000000007;
int n;
char s[maxn];
int f[2][16];
char mp[] = {'0', '1', '2', '*'};
bool check(int i, int S) {
  if (s[i] != '?' && s[i] != mp[S / 4]) return false;
  if (s[i + 1] != '?' && s[i + 1] != mp[S % 4]) return false;
  return true;
}
void solve() {
  bool o = 0;
  if (s[1] == '?')
    f[o][0] = f[o][1] = f[o][3] = 1;
  else if (s[1] == '*')
    f[o][3] = 1;
  else if (s[1] != '2')
    f[o][s[1] - '0'] = 1;
  for (long long i = (1); i <= (n); ++i) {
    o = !o;
    memset(f[o], 0, sizeof(f[o]));
    for (int S = 0; S < (16); ++S)
      if (check(i, S))
        for (int j = 0; j < (4); ++j) {
          if (S / 4 == 3)
            f[o][S] = (f[o][S] + f[!o][j * 4 + S / 4]) % mod;
          else if (S / 4 == (j == 3) + (S % 4 == 3))
            f[o][S] = (f[o][S] + f[!o][j * 4 + S / 4]) % mod;
        }
  }
  int res = 0;
  for (int S = 0; S < (16); ++S) {
    if (S / 4 == 3 && S % 4 == 1) res = (res + f[o][S]) % mod;
    if (S / 4 < 2 && S % 4 == 0) res = (res + f[o][S]) % mod;
  }
  printf("%d\n", res);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  s[0] = s[n + 1] = '?';
  solve();
  return 0;
}
