l = input()
mod = 10 ** 9 + 7

ln = len(l)
dp = [[0] * 2 for _ in range(ln + 1)]
dp[0][1] = 1

for i, e in enumerate(l, 1):
    # smaller -> smaller
    if e == "1":
        dp[i][0] += dp[i-1][0] * 3
    else:
        dp[i][0] += dp[i-1][0] * 3
    # exact -> smaller
    if e == "1":
        dp[i][0] += dp[i-1][1]
    # exact -> exact
    if e == "1":
        dp[i][1] += dp[i-1][1] * 2
    else:
        dp[i][1] += dp[i-1][1]

    dp[i][0] %= mod
    dp[i][1] %= mod

ans = dp[ln][0] + dp[ln][1]
ans %= mod
print(ans)
#print(*dp, sep="\n") l = input() l input() input mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 ln = len(l) ln len(l) len l [0] * 2 for _ in range(ln + 1) for _ in range(ln + 1) _ range(ln + 1) range ln + 1 ln 1 for _ in range(ln + 1) [0] * 2 [0] 0 2 dp = [[0] * 2 for _ in range(ln + 1)] dp [[0] * 2 for _ in range(ln + 1)] dp[0][1] = 1 dp[0][1] [0] dp 0 1 1 for i, e in enumerate(l, 1):
    # smaller -> smaller
    if e == "1":
        dp[i][0] += dp[i-1][0] * 3
    else:
        dp[i][0] += dp[i-1][0] * 3
    # exact -> smaller
    if e == "1":
        dp[i][0] += dp[i-1][1]
    # exact -> exact
    if e == "1":
        dp[i][1] += dp[i-1][1] * 2
    else:
        dp[i][1] += dp[i-1][1]

    dp[i][0] %= mod
    dp[i][1] %= mod i e enumerate(l, 1) enumerate l 1 if e == "1":
        dp[i][0] += dp[i-1][0] * 3
    else:
        dp[i][0] += dp[i-1][0] * 3
    # exact -> smaller
     e == "1" e "1" dp[i][0] += dp[i-1][0] * 3 dp[i][0] [i] dp i 0 dp[i-1][0] * 3 dp[i-1][0] [i-1] dp i-1 i 1 0 3 dp[i][0] += dp[i-1][0] * 3 dp[i][0] [i] dp i 0 dp[i-1][0] * 3 dp[i-1][0] [i-1] dp i-1 i 1 0 3 if e == "1":
        dp[i][0] += dp[i-1][1]
    # exact -> exact
     e == "1" e "1" dp[i][0] += dp[i-1][1] dp[i][0] [i] dp i 0 dp[i-1][1] [i-1] dp i-1 i 1 1 if e == "1":
        dp[i][1] += dp[i-1][1] * 2
    else:
        dp[i][1] += dp[i-1][1]

     e == "1" e "1" dp[i][1] += dp[i-1][1] * 2 dp[i][1] [i] dp i 1 dp[i-1][1] * 2 dp[i-1][1] [i-1] dp i-1 i 1 1 2 dp[i][1] += dp[i-1][1] dp[i][1] [i] dp i 1 dp[i-1][1] [i-1] dp i-1 i 1 1 dp[i][0] %= mod dp[i][0] [i] dp i 0 mod dp[i][1] %= mod dp[i][1] [i] dp i 1 mod ans = dp[ln][0] + dp[ln][1] ans dp[ln][0] + dp[ln][1] dp[ln][0] [ln] dp ln 0 dp[ln][1] [ln] dp ln 1 ans %= mod ans mod print(ans) print ans l = input() input() l mod = 10 ** 9 + 7 10 ** 9 + 7 mod ans %= mod mod ans ans = dp[ln][0] + dp[ln][1] dp[ln][0] + dp[ln][1] ans dp = [[0] * 2 for _ in range(ln + 1)] [[0] * 2 for _ in range(ln + 1)] dp ln = len(l) len(l) ln
l = input()
mod = 10 ** 9 + 7

ln = len(l)
dp = [[0] * 2 for _ in range(ln + 1)]
dp[0][1] = 1

for i, e in enumerate(l, 1):
    # smaller -> smaller
    if e == "1":
        dp[i][0] += dp[i-1][0] * 3
    else:
        dp[i][0] += dp[i-1][0] * 3
    # exact -> smaller
    if e == "1":
        dp[i][0] += dp[i-1][1]
    # exact -> exact
    if e == "1":
        dp[i][1] += dp[i-1][1] * 2
    else:
        dp[i][1] += dp[i-1][1]

    dp[i][0] %= mod
    dp[i][1] %= mod

ans = dp[ln][0] + dp[ln][1]
ans %= mod
print(ans)
#print(*dp, sep="\n")
