import sys

L = list(sys.stdin.readline().strip())
mod = 10**9 + 7
ls = len(L)

# 左からi桁目で、L以下が確定しているかどうか（True /False）の場合の(a, b)の組み合わせの総数
dp = [[0 for i in (True, False)] for _ in range(ls)]
# 1からしか始まらない
dp[0][False] = 2
dp[0][True] = 1
 
for i in range(ls-1):
    for j in (True, False):
        if L[i+1] == "1":
            dp[i+1][True] = 3 * dp[i][True] + 1 * dp[i][False]
            dp[i+1][False] = 2 * dp[i][False]
        else:
            dp[i+1][True] = 3 * dp[i][True]
            # dp[i+1][False] = 1 * dp[i][False]
            dp[i+1][False] = 1 * dp[i][False]
        dp[i+1][True] %= mod
        dp[i+1][False] %= mod
 
print(sum(dp[ls-1]) % mod) import sys sys L = list(sys.stdin.readline().strip()) L list(sys.stdin.readline().strip()) list sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 ls = len(L) ls len(L) len L [0 for i in (True, False)] for _ in range(ls) for _ in range(ls) _ range(ls) range ls for _ in range(ls) [0 for i in (True, False)] dp = [[0 for i in (True, False)] for _ in range(ls)] dp [[0 for i in (True, False)] for _ in range(ls)] dp[0][False] = 2 dp[0][False] [0] dp 0 False 2 dp[0][True] = 1 dp[0][True] [0] dp 0 True 1 for i in range(ls-1):
    for j in (True, False):
        if L[i+1] == "1":
            dp[i+1][True] = 3 * dp[i][True] + 1 * dp[i][False]
            dp[i+1][False] = 2 * dp[i][False]
        else:
            dp[i+1][True] = 3 * dp[i][True]
            # dp[i+1][False] = 1 * dp[i][False]
            dp[i+1][False] = 1 * dp[i][False]
        dp[i+1][True] %= mod
        dp[i+1][False] %= mod
  i range(ls-1) range ls-1 ls 1 for j in (True, False):
        if L[i+1] == "1":
            dp[i+1][True] = 3 * dp[i][True] + 1 * dp[i][False]
            dp[i+1][False] = 2 * dp[i][False]
        else:
            dp[i+1][True] = 3 * dp[i][True]
            # dp[i+1][False] = 1 * dp[i][False]
            dp[i+1][False] = 1 * dp[i][False]
        dp[i+1][True] %= mod
        dp[i+1][False] %= mod
  j (True, False) True False if L[i+1] == "1":
            dp[i+1][True] = 3 * dp[i][True] + 1 * dp[i][False]
            dp[i+1][False] = 2 * dp[i][False]
        else:
            dp[i+1][True] = 3 * dp[i][True]
            # dp[i+1][False] = 1 * dp[i][False]
            dp[i+1][False] = 1 * dp[i][False]
         L[i+1] == "1" L[i+1] L i+1 i 1 "1" dp[i+1][True] = 3 * dp[i][True] + 1 * dp[i][False] dp[i+1][True] [i+1] dp i+1 i 1 True 3 * dp[i][True] + 1 * dp[i][False] 3 * dp[i][True] 3 dp[i][True] [i] dp i True 1 * dp[i][False] 1 dp[i][False] [i] dp i False dp[i+1][False] = 2 * dp[i][False] dp[i+1][False] [i+1] dp i+1 i 1 False 2 * dp[i][False] 2 dp[i][False] [i] dp i False dp[i+1][True] = 3 * dp[i][True] dp[i+1][True] [i+1] dp i+1 i 1 True 3 * dp[i][True] 3 dp[i][True] [i] dp i True dp[i+1][False] = 1 * dp[i][False] dp[i+1][False] [i+1] dp i+1 i 1 False 1 * dp[i][False] 1 dp[i][False] [i] dp i False dp[i+1][True] %= mod dp[i+1][True] [i+1] dp i+1 i 1 True mod dp[i+1][False] %= mod dp[i+1][False] [i+1] dp i+1 i 1 False mod print(sum(dp[ls-1]) % mod) print sum(dp[ls-1]) % mod sum(dp[ls-1]) sum dp[ls-1] dp ls-1 ls 1 mod dp = [[0 for i in (True, False)] for _ in range(ls)] [[0 for i in (True, False)] for _ in range(ls)] dp L = list(sys.stdin.readline().strip()) list(sys.stdin.readline().strip()) L mod = 10**9 + 7 10**9 + 7 mod ls = len(L) len(L) ls
import sys

L = list(sys.stdin.readline().strip())
mod = 10**9 + 7
ls = len(L)

# 左からi桁目で、L以下が確定しているかどうか（True /False）の場合の(a, b)の組み合わせの総数
dp = [[0 for i in (True, False)] for _ in range(ls)]
# 1からしか始まらない
dp[0][False] = 2
dp[0][True] = 1
 
for i in range(ls-1):
    for j in (True, False):
        if L[i+1] == "1":
            dp[i+1][True] = 3 * dp[i][True] + 1 * dp[i][False]
            dp[i+1][False] = 2 * dp[i][False]
        else:
            dp[i+1][True] = 3 * dp[i][True]
            # dp[i+1][False] = 1 * dp[i][False]
            dp[i+1][False] = 1 * dp[i][False]
        dp[i+1][True] %= mod
        dp[i+1][False] %= mod
 
print(sum(dp[ls-1]) % mod)