# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 桁DP, Lを超えないものと保留のもの
MOD = 10 ** 9 + 7
L = sr()
dp = [1, 2]
length = len(L)
for i in range(1, length):
    prev = dp[:]
    if L[i] == '1':
        dp[0] = prev[0] * 3 + prev[1]
        dp[1] = prev[1] * 2
    else:
        dp[0] = prev[0] * 3
        dp[1] = prev[1]
    dp[0] %= MOD
    dp[1] %= MOD

answer = sum(dp)
print(answer%MOD) import sys sys sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 L = sr() L sr() sr dp = [1, 2] dp [1, 2] 1 2 length = len(L) length len(L) len L for i in range(1, length):
    prev = dp[:]
    if L[i] == '1':
        dp[0] = prev[0] * 3 + prev[1]
        dp[1] = prev[1] * 2
    else:
        dp[0] = prev[0] * 3
        dp[1] = prev[1]
    dp[0] %= MOD
    dp[1] %= MOD i range(1, length) range 1 length prev = dp[:] prev dp[:] dp : if L[i] == '1':
        dp[0] = prev[0] * 3 + prev[1]
        dp[1] = prev[1] * 2
    else:
        dp[0] = prev[0] * 3
        dp[1] = prev[1]
     L[i] == '1' L[i] L i '1' dp[0] = prev[0] * 3 + prev[1] dp[0] dp 0 prev[0] * 3 + prev[1] prev[0] * 3 prev[0] prev 0 3 prev[1] prev 1 dp[1] = prev[1] * 2 dp[1] dp 1 prev[1] * 2 prev[1] prev 1 2 dp[0] = prev[0] * 3 dp[0] dp 0 prev[0] * 3 prev[0] prev 0 3 dp[1] = prev[1] dp[1] dp 1 prev[1] prev 1 dp[0] %= MOD dp[0] dp 0 MOD dp[1] %= MOD dp[1] dp 1 MOD answer = sum(dp) answer sum(dp) sum dp print(answer%MOD) print answer%MOD answer MOD length = len(L) len(L) length L = sr() sr() L sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr prev = dp[:] dp[:] prev MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD dp = [1, 2] [1, 2] dp lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr ir = lambda: int(sr()) lambda: int(sr()) ir answer = sum(dp) sum(dp) answer
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 桁DP, Lを超えないものと保留のもの
MOD = 10 ** 9 + 7
L = sr()
dp = [1, 2]
length = len(L)
for i in range(1, length):
    prev = dp[:]
    if L[i] == '1':
        dp[0] = prev[0] * 3 + prev[1]
        dp[1] = prev[1] * 2
    else:
        dp[0] = prev[0] * 3
        dp[1] = prev[1]
    dp[0] %= MOD
    dp[1] %= MOD

answer = sum(dp)
print(answer%MOD)
