#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
inline long long input() {
  long long n;
  cin >> n;
  return n;
}
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const long long INF = 8e18;
long long dp[MAXN][5];
int arr[MAXN];
long long ans;
int jko(string s) {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?') return i;
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  string s;
  cin >> s;
  long long n = s.size();
  for (int i = 0; i < s.size(); i++) {
    switch (s[i]) {
      case '0':
        arr[i] = 0;
        break;
      case '1':
        arr[i] = 1;
        break;
      case '2':
        arr[i] = 2;
        break;
      case '*':
        arr[i] = 3;
        break;
      case '?':
        arr[i] = 4;
        break;
    }
  }
  if (arr[0] == 0) {
    dp[0][0] = 1;
  }
  if (arr[0] == 1) {
    dp[0][2] = 1;
  }
  if (arr[0] == 3) {
    dp[0][4] = 1;
  }
  if (arr[0] == 4) {
    dp[0][0] = 1;
    dp[0][2] = 1;
    dp[0][4] = 1;
  }
  for (int i = 1; i < n; i++) {
    if (arr[i] == 4) {
      dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
      dp[i][1] = (dp[i - 1][4]) % MOD;
      dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
      dp[i][3] = (dp[i - 1][4]) % MOD;
      dp[i][4] = (dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4]) % MOD;
    } else {
      if (arr[i] == 0) {
        dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
      } else {
        if (arr[i] == 1) {
          dp[i][1] = (dp[i - 1][4]) % MOD;
          dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
        } else {
          if (arr[i] == 2) {
            dp[i][3] = (dp[i - 1][4]) % MOD;
          } else {
            if (arr[i] == 3) {
              dp[i][4] = (dp[i - 1][2] + dp[i - 1][3] + dp[i - 1][4]) % MOD;
            }
          }
        }
      }
    }
  }
  n--;
  ans = (dp[n][0] + dp[n][1] + dp[n][4]) % MOD;
  cout << ans << "\n";
}
