import sys

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

L = list(sr())
MOD = 10 ** 9 + 7
bit_len = len(L)

dp_any = 1 # 1桁目が(0, 0)の組み合わせ, dp_any はi+1桁目がどんな数字でも条件を満たす
dp_spe = 2
for i in range(1, bit_len):
    x, y = dp_any, dp_spe
    if L[i] == '1':
        dp_any = x * 3 + y
        dp_spe = y * 2
    else:
        dp_any = x * 3
        dp_spe = y
    dp_any %= MOD
    dp_spe %= MOD

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

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

L = list(sr())
MOD = 10 ** 9 + 7
bit_len = len(L)

dp_any = 1 # 1桁目が(0, 0)の組み合わせ, dp_any はi+1桁目がどんな数字でも条件を満たす
dp_spe = 2
for i in range(1, bit_len):
    x, y = dp_any, dp_spe
    if L[i] == '1':
        dp_any = x * 3 + y
        dp_spe = y * 2
    else:
        dp_any = x * 3
        dp_spe = y
    dp_any %= MOD
    dp_spe %= MOD

answer = (dp_any + dp_spe) % MOD
print(answer)
