#include <bits/stdc++.h>
long long MOD = 1000000007;
long long inf = 10000000000;
using namespace std;
long long Mem[1000001][5];
string s;
long long N;
long long Solve(int i, int type) {
  if (i == N) {
    if (type == 2 || type == 1) {
      return 0;
    }
    return 1;
  }
  if (Mem[i][type] != -1) {
    return Mem[i][type];
  }
  Mem[i][type] = 0;
  if (s[i] != '?') {
    if (s[i] == '0') {
      if (type == 1 || type == 2 || type == 4) {
        return 0;
      }
      Mem[i][type] = Solve(i + 1, 0);
    }
    if (s[i] == '1') {
      if (type == 1 || type == 2) {
        return 0;
      }
      if (type == 4)
        Mem[i][type] = Solve(i + 1, 3);
      else
        Mem[i][type] = Solve(i + 1, 1);
    }
    if (s[i] == '2') {
      if (type != 4) {
        return 0;
      }
      Mem[i][type] = Solve(i + 1, 2);
    }
    if (s[i] == '*') {
      if (type == 0 || type == 3) {
        return 0;
      }
      Mem[i][type] = Solve(i + 1, 4);
    }
    return Mem[i][type];
  }
  if (type == 0) {
    Mem[i][type] += Solve(i + 1, 1);
    Mem[i][type] += Solve(i + 1, 0);
    Mem[i][type] %= MOD;
  }
  if (type == 1) {
    Mem[i][type] += Solve(i + 1, 4);
  }
  if (type == 2) {
    Mem[i][type] += Solve(i + 1, 4);
  }
  if (type == 3) {
    Mem[i][type] += Solve(i + 1, 0);
    Mem[i][type] += Solve(i + 1, 1);
    Mem[i][type] %= MOD;
  }
  if (type == 4) {
    Mem[i][type] += Solve(i + 1, 3);
    Mem[i][type] += Solve(i + 1, 2);
    Mem[i][type] %= MOD;
    Mem[i][type] += Solve(i + 1, 4);
    Mem[i][type] %= MOD;
  }
  return Mem[i][type];
}
int main() {
  ios::sync_with_stdio(false);
  long long i, j;
  for (i = 0; i < 1000001; i++) {
    for (j = 0; j < 5; j++) {
      Mem[i][j] = -1;
    }
  }
  cin >> s;
  N = s.size();
  long long ans = 0;
  if (s[0] == '?') {
    for (i = 0; i < 5; i++) {
      if (i == 3 || i == 2) {
        continue;
      }
      ans += Solve(1, i);
      ans %= MOD;
    }
  } else if (s[0] == '*') {
    ans = Solve(0, 1);
  } else {
    ans = Solve(0, 0);
  }
  cout << ans;
  return 0;
}
