#include <bits/stdc++.h>
const int MaxN = 1e6;
const int Pt = 1e9 + 7;
using namespace std;
char s[MaxN + 5];
long long f[MaxN + 5][5];
int main() {
  while (~scanf("%s", s + 1)) {
    int len = strlen(s + 1);
    memset(f, 0, sizeof(f));
    if (s[1] == '?') {
      f[1][0] = 1;
      f[1][1] = f[1][4] = 1;
      f[1][2] = f[1][3] = 0;
    } else if (s[1] == '0')
      f[1][0] = 1;
    else if (s[1] == '1')
      f[1][1] = 1;
    else if (s[1] == '2')
      f[1][2] = 0;
    else if (s[1] == '*')
      f[1][4] = 1;
    for (int i = 2; i <= len; i++) {
      if (s[i] == '?') {
        f[i][0] = (f[i - 1][0] + f[i - 1][3]) % Pt;
        f[i][1] = (f[i - 1][0] + f[i - 1][3]) % Pt;
        f[i][2] = (f[i - 1][4]) % Pt;
        f[i][3] = f[i - 1][4] % Pt;
        f[i][4] = (f[i - 1][4] + f[i - 1][1] + f[i - 1][2]) % Pt;
      } else if (s[i] == '1') {
        f[i][1] = (f[i - 1][0] + f[i - 1][3]) % Pt;
        f[i][3] = f[i - 1][4] % Pt;
      } else if (s[i] == '0')
        f[i][0] = (f[i - 1][0] + f[i - 1][3]) % Pt;
      else if (s[i] == '2')
        f[i][2] = (f[i - 1][4]) % Pt;
      else if (s[i] == '*')
        f[i][4] = (f[i - 1][4] + f[i - 1][1] + f[i - 1][2]) % Pt;
    }
    printf("%d\n", (f[len][0] + f[len][3] + f[len][4]) % Pt);
  }
}
