# 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_dec = 1 # decide
dp_res = 2 # reserve
length = len(L)
for i in range(1, length):
    x, y = dp_dec, dp_res
    if L[i] == '1':
        dp_dec = x * 3 + y
        dp_res = y * 2
    else:
        dp_dec = x * 3
        dp_res = y
    dp_dec %= MOD
    dp_res %= MOD

answer = dp_dec + dp_res
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_dec = 1 dp_dec 1 dp_res = 2 dp_res 2 length = len(L) length len(L) len L for i in range(1, length):
    x, y = dp_dec, dp_res
    if L[i] == '1':
        dp_dec = x * 3 + y
        dp_res = y * 2
    else:
        dp_dec = x * 3
        dp_res = y
    dp_dec %= MOD
    dp_res %= MOD i range(1, length) range 1 length x, y = dp_dec, dp_res x dp_dec y dp_res if L[i] == '1':
        dp_dec = x * 3 + y
        dp_res = y * 2
    else:
        dp_dec = x * 3
        dp_res = y
     L[i] == '1' L[i] L i '1' dp_dec = x * 3 + y dp_dec x * 3 + y x * 3 x 3 y dp_res = y * 2 dp_res y * 2 y 2 dp_dec = x * 3 dp_dec x * 3 x 3 dp_res = y dp_res y dp_dec %= MOD dp_dec MOD dp_res %= MOD dp_res MOD answer = dp_dec + dp_res answer dp_dec + dp_res dp_dec dp_res print(answer % MOD) print answer % MOD answer MOD L = sr() sr() L sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr y = dp_dec, dp_res dp_res y lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr dp_dec = x * 3 x * 3 dp_dec answer = dp_dec + dp_res dp_dec + dp_res answer ir = lambda: int(sr()) lambda: int(sr()) ir dp_res = 2 2 dp_res length = len(L) len(L) length MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD dp_dec = 1 1 dp_dec dp_res = y * 2 y * 2 dp_res dp_dec = x * 3 + y x * 3 + y dp_dec dp_res = y y dp_res dp_res %= MOD MOD dp_res x, y = dp_dec, dp_res dp_dec x dp_dec %= MOD MOD dp_dec
# 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_dec = 1 # decide
dp_res = 2 # reserve
length = len(L)
for i in range(1, length):
    x, y = dp_dec, dp_res
    if L[i] == '1':
        dp_dec = x * 3 + y
        dp_res = y * 2
    else:
        dp_dec = x * 3
        dp_res = y
    dp_dec %= MOD
    dp_res %= MOD

answer = dp_dec + dp_res
print(answer % MOD)
