#include <bits/stdc++.h>
using namespace std;
string s;
int n, dp[((int)1e6 + 5)][2][3], want;
int f(int k, bool issol, int isn) {
  if (k == n + 1) return isn != 2;
  int &r = dp[k][issol][isn];
  if (r != -1) return r;
  r = 0;
  if (s[k] >= '0' and s[k] <= '2' and isn == 2) return r = 0;
  if (s[k] == '0') {
    if (issol) return r = 0;
    return r = f(k + 1, 0, 1);
  }
  if (s[k] == '1') {
    if (issol) return r = f(k + 1, 0, 1);
    return r = f(k + 1, 0, 2);
  }
  if (s[k] == '2') {
    if (!issol) return r = 0;
    return r = f(k + 1, 0, 2);
  }
  if (s[k] == '*') {
    if (isn == 1) return r = 0;
    return r = f(k + 1, 1, 0);
  }
  if (s[k] == '?') {
    if (isn != 2 and issol) {
      r = (r + f(k + 1, 0, 1)) % 1000000007;
      if (k == want) cout << r << '\n';
      r = (r + f(k + 1, 0, 2)) % 1000000007;
      if (k == want) cout << r << '\n';
    } else if (isn != 2) {
      r = (r + f(k + 1, 0, 1)) % 1000000007;
      if (k == want) cout << r << '\n';
      r = (r + f(k + 1, 0, 2)) % 1000000007;
      if (k == want) cout << r << '\n';
    }
    if (isn != 1) r = (r + f(k + 1, 1, 0)) % 1000000007;
    if (k == want) cout << r << '\n';
    if (k == want) cout << '\n';
    return r;
  }
}
int main() {
  memset(dp, -1, sizeof(dp));
  want = -1;
  cin >> s;
  n = s.size();
  s = '0' + s;
  cout << f(1, 0, 0) << '\n';
  return 0;
}
