#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
const ll MOD=1e9+7;
modint<MOD> dp[350000][2][7][4];

main(){
    string s;cin>>s;
    if(s[0]=='?'){
        dp[0][0][2][0]=1;
        dp[0][0][4][1]=1;
    } 
    else if(s[0]=='1'){
        dp[0][0][4][1]=1;
    }
    else{
        dp[0][0][2][0]=1;
    }
    rep2(i,1,s.size()-1){
        int c=(s[i]=='?' ? 2:(s[i]-'0'));
        rep(j,2){
            rep(k,7){
                if(c!=0){
                    // 1を入れる
                    dp[i][j][min((int)k+1,6)][1]+=dp[i-1][j][k][0];
                    dp[i][0][min((int)k+1,6)][3]+=dp[i-1][j][k][1]+dp[i-1][j][k][3];
                    dp[i][1][min((int)k+1,6)][1]+=dp[i-1][j][k][2];
                }
                if(c!=1){
                    if(j)
                    dp[i][0][k+1][0]+=dp[i-1][j][k][0];
                    else if(k)
                    dp[i][j][k-1][2]+=dp[i-1][j][k][0];
                    if(k){
                        dp[i][j][k-1][0]+=dp[i-1][j][k][1];
                        dp[i][j][k-1][0]+=dp[i-1][j][k][3];
                    }
                    dp[i][j][k+1][0]+=dp[i-1][j][k][2];
                }
            }
        }
        rep(j,2)rep(k,7)rep(l,4){
        // if(dp[i][j][k][l].a)
        // cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<dp[i][j][k][l].a<<endl;
        }
    }
    modint<MOD> ans=0;
    rep(j,2)rep2(k,3,6)rep(l,4){
        // if(dp[s.size()-1][j][k][l].a) cout<<j<<" "<<k<<" "<<l<<" "<<dp[s.size()-1][j][k][l].a<<endl;
        ans+=dp[s.size()-1][j][k][l];
    }
    cout<<ans.a;
}

Measured memory_bytes: 133764