import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    L = list(input())
    n = len(L)

    dp = [[0] * 2 for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        if L[i - 1] == "0":
            dp[i][0] = dp[i - 1][0]
            dp[i][1] = (dp[i - 1][1] * 3) % mod
        else:
            dp[i][0] = (dp[i - 1][0] * 2) % mod
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod

    print((dp[-1][0] + dp[-1][1]) % mod)


if __name__ == '__main__':
    resolve() import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 f_inf = float('inf') f_inf float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def resolve():
    L = list(input())
    n = len(L)

    dp = [[0] * 2 for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        if L[i - 1] == "0":
            dp[i][0] = dp[i - 1][0]
            dp[i][1] = (dp[i - 1][1] * 3) % mod
        else:
            dp[i][0] = (dp[i - 1][0] * 2) % mod
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod

    print((dp[-1][0] + dp[-1][1]) % mod) resolve L = list(input()) L list(input()) list input() input n = len(L) n len(L) len L [0] * 2 for _ in range(n + 1) for _ in range(n + 1) _ range(n + 1) range n + 1 n 1 for _ in range(n + 1) [0] * 2 [0] 0 2 dp = [[0] * 2 for _ in range(n + 1)] dp [[0] * 2 for _ in range(n + 1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(1, n + 1):
        if L[i - 1] == "0":
            dp[i][0] = dp[i - 1][0]
            dp[i][1] = (dp[i - 1][1] * 3) % mod
        else:
            dp[i][0] = (dp[i - 1][0] * 2) % mod
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod

     i range(1, n + 1) range 1 n + 1 n 1 if L[i - 1] == "0":
            dp[i][0] = dp[i - 1][0]
            dp[i][1] = (dp[i - 1][1] * 3) % mod
        else:
            dp[i][0] = (dp[i - 1][0] * 2) % mod
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod

     L[i - 1] == "0" L[i - 1] L i - 1 i 1 "0" dp[i][0] = dp[i - 1][0] dp[i][0] [i] dp i 0 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 dp[i][1] = (dp[i - 1][1] * 3) % mod dp[i][1] [i] dp i 1 (dp[i - 1][1] * 3) % mod dp[i - 1][1] * 3 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 3 mod dp[i][0] = (dp[i - 1][0] * 2) % mod dp[i][0] [i] dp i 0 (dp[i - 1][0] * 2) % mod dp[i - 1][0] * 2 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 2 mod dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod dp[i][1] [i] dp i 1 (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod dp[i - 1][1] * 3 + dp[i - 1][0] dp[i - 1][1] * 3 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 3 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 mod print((dp[-1][0] + dp[-1][1]) % mod) print (dp[-1][0] + dp[-1][1]) % mod dp[-1][0] + dp[-1][1] dp[-1][0] [-1] dp -1 0 dp[-1][1] [-1] dp -1 1 mod if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve mod = 10 ** 9 + 7 10 ** 9 + 7 mod f_inf = float('inf') float('inf') f_inf def resolve():
    L = list(input())
    n = len(L)

    dp = [[0] * 2 for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        if L[i - 1] == "0":
            dp[i][0] = dp[i - 1][0]
            dp[i][1] = (dp[i - 1][1] * 3) % mod
        else:
            dp[i][0] = (dp[i - 1][0] * 2) % mod
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod

    print((dp[-1][0] + dp[-1][1]) % mod) def resolve():
    L = list(input())
    n = len(L)

    dp = [[0] * 2 for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        if L[i - 1] == "0":
            dp[i][0] = dp[i - 1][0]
            dp[i][1] = (dp[i - 1][1] * 3) % mod
        else:
            dp[i][0] = (dp[i - 1][0] * 2) % mod
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod

    print((dp[-1][0] + dp[-1][1]) % mod) resolve
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    L = list(input())
    n = len(L)

    dp = [[0] * 2 for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        if L[i - 1] == "0":
            dp[i][0] = dp[i - 1][0]
            dp[i][1] = (dp[i - 1][1] * 3) % mod
        else:
            dp[i][0] = (dp[i - 1][0] * 2) % mod
            dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 1][0]) % mod

    print((dp[-1][0] + dp[-1][1]) % mod)


if __name__ == '__main__':
    resolve()
