#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6, MOD = 1000000007;
long long memo[N][6][6];
int n;
string s;
bool invalid(int i, int last, int before_last) {
  if (last == 1 &&
      (s[i] == '*' || s[i] == '2' || before_last == 4 || before_last == 3)) {
    return 1;
  }
  if (last == 2 && before_last != 4 && s[i] != '*' && s[i] != '?') {
    return 1;
  }
  if (last == 2 && s[i] == '*' && before_last == 4) return 1;
  if (last == 3) {
    if ((s[i] == '*' && before_last != 4) ||
        (s[i] == '?' && before_last != 4) || (s[i] != '*' && s[i] != '?'))
      return 1;
  }
  if (last == 4 && (before_last == 1 || s[i] == '0')) {
    return 1;
  }
  return 0;
}
long long solve(int i, int last, int before_last) {
  if (invalid(i, last, before_last)) {
    return 0;
  }
  if (i == n) {
    return 1;
  }
  long long &ret = memo[i][last][before_last];
  if (ret != -1) {
    return ret % MOD;
  }
  ret = 0;
  if (s[i] == '?' && last == 0) {
    if (i + 1 < n) {
      if (s[i + 1] == '*') {
        ret += solve(i + 1, 2, last) % MOD;
        ret += solve(i + 1, 4, last) % MOD;
      } else if (s[i + 1] == '2') {
        ret += solve(i + 1, 4, last) % MOD;
      } else if (s[i + 1] == '1') {
        ret += solve(i + 1, 4, last) % MOD;
        ret += solve(i + 1, 1, last) % MOD;
      } else {
        ret += solve(i + 1, 1, last) % MOD;
        ret += solve(i + 1, 2, last) % MOD;
        ret += solve(i + 1, 4, last) % MOD;
      }
    } else {
      ret += solve(i + 1, 1, last) % MOD;
      ret += solve(i + 1, 4, last) % MOD;
    }
  } else if (s[i] == '?' && last == 3) {
    ret += solve(i + 1, 4, last) % MOD;
  } else if (s[i] == '?' && last == 2) {
    if (before_last == 4) {
      ret += solve(i + 1, 1, last) % MOD;
      ret += solve(i + 1, 2, last) % MOD;
    } else if (before_last != 4) {
      ret += solve(i + 1, 4, last) % MOD;
    }
  } else if (s[i] == '?' && last == 1) {
    ret += solve(i + 1, 1, last) % MOD;
    ret += solve(i + 1, 2, last) % MOD;
  } else if (s[i] == '?' && last == 4) {
    ret += solve(i + 1, 3, last) % MOD;
    ret += solve(i + 1, 2, last) % MOD;
    ret += solve(i + 1, 4, last) % MOD;
  } else {
    if (s[i] == '1') {
      ret += solve(i + 1, 2, last) % MOD;
    } else if (s[i] == '2') {
      ret += solve(i + 1, 3, last) % MOD;
    } else if (s[i] == '0') {
      ret += solve(i + 1, 1, last) % MOD;
    } else {
      ret += solve(i + 1, 4, last) % MOD;
    }
  }
  return ret % MOD;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  memset(memo, -1, sizeof memo);
  cin >> s;
  n = s.size();
  s += '7';
  cout << solve(0, 0, 0) % MOD << endl;
}
