import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = readline().decode().rstrip()
L = len(N)
dp = [[0]*2 for _ in range(L+1)]
dp[0][0] = 1
for i in range(L):
    nd = int(N[i])
    if nd == 0:
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = (3 * dp[i][1]) % MOD
    else:    
        dp[i+1][0] = 2 * dp[i][0] % MOD
        dp[i+1][1] = (3 * dp[i][1] + dp[i][0]) % MOD
print(sum(dp[L])%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 N = readline().decode().rstrip() N readline().decode().rstrip() ().decode().rstrip ().decode() ().decode () readline decode rstrip L = len(N) L len(N) len N [0]*2 for _ in range(L+1) for _ in range(L+1) _ range(L+1) range L+1 L 1 for _ in range(L+1) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(L+1)] dp [[0]*2 for _ in range(L+1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(L):
    nd = int(N[i])
    if nd == 0:
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = (3 * dp[i][1]) % MOD
    else:    
        dp[i+1][0] = 2 * dp[i][0] % MOD
        dp[i+1][1] = (3 * dp[i][1] + dp[i][0]) % MOD i range(L) range L nd = int(N[i]) nd int(N[i]) int N[i] N i if nd == 0:
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = (3 * dp[i][1]) % MOD
    else:    
        dp[i+1][0] = 2 * dp[i][0] % MOD
        dp[i+1][1] = (3 * dp[i][1] + dp[i][0]) % MOD nd == 0 nd 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] = (3 * dp[i][1]) % MOD dp[i+1][1] [i+1] dp i+1 i 1 1 (3 * dp[i][1]) % MOD 3 * dp[i][1] 3 dp[i][1] [i] dp i 1 MOD dp[i+1][0] = 2 * dp[i][0] % MOD dp[i+1][0] [i+1] dp i+1 i 1 0 2 * dp[i][0] % MOD 2 * dp[i][0] 2 dp[i][0] [i] dp i 0 MOD dp[i+1][1] = (3 * dp[i][1] + dp[i][0]) % MOD dp[i+1][1] [i+1] dp i+1 i 1 1 (3 * dp[i][1] + dp[i][0]) % MOD 3 * dp[i][1] + dp[i][0] 3 * dp[i][1] 3 dp[i][1] [i] dp i 1 dp[i][0] [i] dp i 0 MOD print(sum(dp[L])%MOD) print sum(dp[L])%MOD sum(dp[L]) sum dp[L] dp L MOD dp = [[0]*2 for _ in range(L+1)] [[0]*2 for _ in range(L+1)] dp N = readline().decode().rstrip() readline().decode().rstrip() N readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline read = sys.stdin.buffer.read sys.stdin.buffer.read read readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines nd = int(N[i]) int(N[i]) nd MOD = 10**9+7 10**9+7 MOD L = len(N) len(N) L
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = readline().decode().rstrip()
L = len(N)
dp = [[0]*2 for _ in range(L+1)]
dp[0][0] = 1
for i in range(L):
    nd = int(N[i])
    if nd == 0:
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = (3 * dp[i][1]) % MOD
    else:    
        dp[i+1][0] = 2 * dp[i][0] % MOD
        dp[i+1][1] = (3 * dp[i][1] + dp[i][0]) % MOD
print(sum(dp[L])%MOD)
