import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 桁DPで解いてみる

L = input()
N = len(L)
MOD = 10 ** 9 + 7

dp = [[0] * 2 for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    # a + b = 0 にするやり方
    if L[i] == '0':
        dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = dp[i][1]
    elif L[i] == '1':
        #dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD

    # a + b = 1 にするやり方
    if L[i] == '0':
        # 小さいやつから出ないとこれは作れない
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD
    elif L[i] == '1':
        dp[i + 1][0] += dp[i][0] * 2 % MOD
        dp[i + 1][0] %= MOD
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD

ans = (dp[N][0] + dp[N][1]) % MOD
print(ans) import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines L = input() L input() input N = len(L) N len(L) len L MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 [0] * 2 for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [0] * 2 [0] 0 2 dp = [[0] * 2 for _ in range(N+1)] dp [[0] * 2 for _ in range(N+1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(N):
    # a + b = 0 にするやり方
    if L[i] == '0':
        dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = dp[i][1]
    elif L[i] == '1':
        #dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD

    # a + b = 1 にするやり方
    if L[i] == '0':
        # 小さいやつから出ないとこれは作れない
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD
    elif L[i] == '1':
        dp[i + 1][0] += dp[i][0] * 2 % MOD
        dp[i + 1][0] %= MOD
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD i range(N) range N if L[i] == '0':
        dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = dp[i][1]
    elif L[i] == '1':
        #dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD

    # a + b = 1 にするやり方
     L[i] == '0' L[i] L i '0' dp[i + 1][0] = dp[i][0] dp[i + 1][0] [i + 1] dp i + 1 i 1 0 dp[i][0] [i] dp i 0 dp[i + 1][1] = dp[i][1] dp[i + 1][1] [i + 1] dp i + 1 i 1 1 dp[i][1] [i] dp i 1 elif L[i] == '1':
        #dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD

    # a + b = 1 にするやり方
     L[i] == '1' L[i] L i '1' dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD dp[i + 1][1] [i + 1] dp i + 1 i 1 1 (dp[i][0] + dp[i][1]) % MOD dp[i][0] + dp[i][1] dp[i][0] [i] dp i 0 dp[i][1] [i] dp i 1 MOD if L[i] == '0':
        # 小さいやつから出ないとこれは作れない
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD
    elif L[i] == '1':
        dp[i + 1][0] += dp[i][0] * 2 % MOD
        dp[i + 1][0] %= MOD
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD L[i] == '0' L[i] L i '0' dp[i + 1][1] += dp[i][1] * 2 % MOD dp[i + 1][1] [i + 1] dp i + 1 i 1 1 dp[i][1] * 2 % MOD dp[i][1] * 2 dp[i][1] [i] dp i 1 2 MOD dp[i + 1][1] %= MOD dp[i + 1][1] [i + 1] dp i + 1 i 1 1 MOD elif L[i] == '1':
        dp[i + 1][0] += dp[i][0] * 2 % MOD
        dp[i + 1][0] %= MOD
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD L[i] == '1' L[i] L i '1' dp[i + 1][0] += dp[i][0] * 2 % MOD dp[i + 1][0] [i + 1] dp i + 1 i 1 0 dp[i][0] * 2 % MOD dp[i][0] * 2 dp[i][0] [i] dp i 0 2 MOD dp[i + 1][0] %= MOD dp[i + 1][0] [i + 1] dp i + 1 i 1 0 MOD dp[i + 1][1] += dp[i][1] * 2 % MOD dp[i + 1][1] [i + 1] dp i + 1 i 1 1 dp[i][1] * 2 % MOD dp[i][1] * 2 dp[i][1] [i] dp i 1 2 MOD dp[i + 1][1] %= MOD dp[i + 1][1] [i + 1] dp i + 1 i 1 1 MOD ans = (dp[N][0] + dp[N][1]) % MOD ans (dp[N][0] + dp[N][1]) % MOD dp[N][0] + dp[N][1] dp[N][0] [N] dp N 0 dp[N][1] [N] dp N 1 MOD print(ans) print ans dp = [[0] * 2 for _ in range(N+1)] [[0] * 2 for _ in range(N+1)] dp L = input() input() L readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines read = sys.stdin.buffer.read sys.stdin.buffer.read read MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD N = len(L) len(L) N ans = (dp[N][0] + dp[N][1]) % MOD (dp[N][0] + dp[N][1]) % MOD ans
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 桁DPで解いてみる

L = input()
N = len(L)
MOD = 10 ** 9 + 7

dp = [[0] * 2 for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    # a + b = 0 にするやり方
    if L[i] == '0':
        dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = dp[i][1]
    elif L[i] == '1':
        #dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD

    # a + b = 1 にするやり方
    if L[i] == '0':
        # 小さいやつから出ないとこれは作れない
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD
    elif L[i] == '1':
        dp[i + 1][0] += dp[i][0] * 2 % MOD
        dp[i + 1][0] %= MOD
        dp[i + 1][1] += dp[i][1] * 2 % MOD
        dp[i + 1][1] %= MOD

ans = (dp[N][0] + dp[N][1]) % MOD
print(ans)
