# -*- coding: utf-8 -*-
#E - Sum Equals Xor
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
L = readline().decode().rstrip()
S = len(L)

# dp[i][j] : 上からi桁目の数まで見たとき,L以下であることがj(0:未確定/1:確定)
#            であるような条件を満たす組の総数
# S[i] == 0のとき
#   未確定 dp[i-1][0] → (0,0)の1通り  
#   確定 dp[i-1][1] → (0,0)(0,1)(1,0)の3通り
# S[i] == 1のとき
#   未確定 dp[i-1][0] → (0,1)(1,0)の2通り  
#   確定 dp[i-1][1] → (0,0)(0,1)(1,0)の3通り
#       dp[i-1][0] → (0,0)の1通り

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

for i,l in enumerate(L,1):
    if l == '0':
        dp[i][0] = dp[i-1][0] % MOD
        dp[i][1] = 3*dp[i-1][1] % MOD
    else:
        dp[i][0] = 2*dp[i-1][0] % MOD
        dp[i][1] = (3*dp[i-1][1]+dp[i-1][0]) % MOD

print(sum(dp[-1])%MOD) import sys sys 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 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 L = readline().decode().rstrip() L readline().decode().rstrip() ().decode().rstrip ().decode() ().decode () readline decode rstrip S = len(L) S len(L) len L [0]*2 for _ in range(S+1) for _ in range(S+1) _ range(S+1) range S+1 S 1 for _ in range(S+1) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(S+1)] dp [[0]*2 for _ in range(S+1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i,l in enumerate(L,1):
    if l == '0':
        dp[i][0] = dp[i-1][0] % MOD
        dp[i][1] = 3*dp[i-1][1] % MOD
    else:
        dp[i][0] = 2*dp[i-1][0] % MOD
        dp[i][1] = (3*dp[i-1][1]+dp[i-1][0]) % MOD i l enumerate(L,1) enumerate L 1 if l == '0':
        dp[i][0] = dp[i-1][0] % MOD
        dp[i][1] = 3*dp[i-1][1] % MOD
    else:
        dp[i][0] = 2*dp[i-1][0] % MOD
        dp[i][1] = (3*dp[i-1][1]+dp[i-1][0]) % MOD l == '0' l '0' dp[i][0] = dp[i-1][0] % MOD dp[i][0] [i] dp i 0 dp[i-1][0] % MOD dp[i-1][0] [i-1] dp i-1 i 1 0 MOD dp[i][1] = 3*dp[i-1][1] % MOD dp[i][1] [i] dp i 1 3*dp[i-1][1] % MOD 3*dp[i-1][1] 3 dp[i-1][1] [i-1] dp i-1 i 1 1 MOD dp[i][0] = 2*dp[i-1][0] % MOD dp[i][0] [i] dp i 0 2*dp[i-1][0] % MOD 2*dp[i-1][0] 2 dp[i-1][0] [i-1] dp i-1 i 1 0 MOD dp[i][1] = (3*dp[i-1][1]+dp[i-1][0]) % MOD dp[i][1] [i] dp i 1 (3*dp[i-1][1]+dp[i-1][0]) % MOD 3*dp[i-1][1]+dp[i-1][0] 3*dp[i-1][1] 3 dp[i-1][1] [i-1] dp i-1 i 1 1 dp[i-1][0] [i-1] dp i-1 i 1 0 MOD print(sum(dp[-1])%MOD) print sum(dp[-1])%MOD sum(dp[-1]) sum dp[-1] dp -1 MOD readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline S = len(L) len(L) S MOD = 10**9+7 10**9+7 MOD dp = [[0]*2 for _ in range(S+1)] [[0]*2 for _ in range(S+1)] dp read = sys.stdin.buffer.read sys.stdin.buffer.read read readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines L = readline().decode().rstrip() readline().decode().rstrip() L
# -*- coding: utf-8 -*-
#E - Sum Equals Xor
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
L = readline().decode().rstrip()
S = len(L)

# dp[i][j] : 上からi桁目の数まで見たとき,L以下であることがj(0:未確定/1:確定)
#            であるような条件を満たす組の総数
# S[i] == 0のとき
#   未確定 dp[i-1][0] → (0,0)の1通り  
#   確定 dp[i-1][1] → (0,0)(0,1)(1,0)の3通り
# S[i] == 1のとき
#   未確定 dp[i-1][0] → (0,1)(1,0)の2通り  
#   確定 dp[i-1][1] → (0,0)(0,1)(1,0)の3通り
#       dp[i-1][0] → (0,0)の1通り

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

for i,l in enumerate(L,1):
    if l == '0':
        dp[i][0] = dp[i-1][0] % MOD
        dp[i][1] = 3*dp[i-1][1] % MOD
    else:
        dp[i][0] = 2*dp[i-1][0] % MOD
        dp[i][1] = (3*dp[i-1][1]+dp[i-1][0]) % MOD

print(sum(dp[-1])%MOD)