#include <bits/stdc++.h>
using namespace std;
string s;
int statu[1000005], someone;
long long ans = 1, x = 2;
int main() {
  cin >> s;
  s = "$" + s;
  statu[0] = 1;
  statu[s.size() + 1] = 1;
  for (register int i = 1; i <= s.size(); i++) {
    if (s[i] == '*') {
      if (statu[i] == 1) {
        printf("0\n");
        return 0;
      }
      statu[i] = -1;
    }
    if (s[i] != '*' && s[i] != '?') {
      if (statu[i] == -1) {
        printf("0\n");
        return 0;
      }
      statu[i] = 1;
      if (s[i] == '2') {
        if (statu[i - 1] == 1) {
          printf("0\n");
          return 0;
        }
        statu[i - 1] = -1;
        statu[i + 1] = -1;
      }
      if (s[i] == '0') {
        if (statu[i - 1] == -1) {
          printf("0\n");
          return 0;
        }
        statu[i - 1] = 1;
        statu[i + 1] = 1;
      }
    }
  }
  for (register int i = 1; i <= s.size(); i++) {
    if (s[i] == '1') {
      if (statu[i - 1] == -1) {
        if (statu[i + 1] == -1) {
          printf("0\n");
          return 0;
        }
        statu[i + 1] = 1;
      }
      if (statu[i - 1] == 1) {
        if (statu[i + 1] == 1) {
          printf("0\n");
          return 0;
        }
        statu[i + 1] = -1;
      }
    }
  }
  for (register int i = s.size(); i >= 1; i--) {
    if (s[i] == '1') {
      if (statu[i + 1] == -1) {
        if (statu[i - 1] == -1) {
          printf("0\n");
          return 0;
        }
        statu[i - 1] = 1;
      }
      if (statu[i + 1] == 1) {
        if (statu[i - 1] == 1) {
          printf("0\n");
          return 0;
        }
        statu[i - 1] = -1;
      }
    }
  }
  for (register int i = 1; i <= s.size(); i++) {
    if (s[i] == '1' && statu[i - 1] == 0 && statu[i + 1] == 0) {
      someone--;
    }
    if (s[i] != '1' && statu[i] == 0) {
      someone++;
    }
  }
  while (someone > 0) {
    if (someone & 1 == 1) {
      ans *= x;
      ans %= 1000000007;
    }
    someone = someone >> 1;
    x *= x;
    x %= 1000000007;
  }
  printf("%lld\n", ans);
  return 0;
}
