import sys
input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7
l = input()
n = len(l)
dp = [[0, 0] for _ in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    num = l[i - 1]
    if num == "1":
        dp[i][0] = dp[i - 1][0]*2
        dp[i][1] = dp[i - 1][1]*3 + dp[i - 1][0]
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][1]*3
    dp[i][0] %= mod
    dp[i][1] %= mod
print(sum(dp[-1]) % mod) import sys sys input = lambda: sys.stdin.readline().rstrip() input 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 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 l = input() l input() input n = len(l) n len(l) len l [0, 0] for _ in range(n + 1) for _ in range(n + 1) _ range(n + 1) range n + 1 n 1 for _ in range(n + 1) [0, 0] 0 0 dp = [[0, 0] for _ in range(n + 1)] dp [[0, 0] for _ in range(n + 1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(1, n + 1):
    num = l[i - 1]
    if num == "1":
        dp[i][0] = dp[i - 1][0]*2
        dp[i][1] = dp[i - 1][1]*3 + dp[i - 1][0]
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][1]*3
    dp[i][0] %= mod
    dp[i][1] %= mod i range(1, n + 1) range 1 n + 1 n 1 num = l[i - 1] num l[i - 1] l i - 1 i 1 if num == "1":
        dp[i][0] = dp[i - 1][0]*2
        dp[i][1] = dp[i - 1][1]*3 + dp[i - 1][0]
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][1]*3
     num == "1" num "1" dp[i][0] = dp[i - 1][0]*2 dp[i][0] [i] dp i 0 dp[i - 1][0]*2 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 2 dp[i][1] = dp[i - 1][1]*3 + dp[i - 1][0] dp[i][1] [i] dp i 1 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 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 dp[i][1] [i] dp i 1 dp[i - 1][1]*3 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 3 dp[i][0] %= mod dp[i][0] [i] dp i 0 mod dp[i][1] %= mod dp[i][1] [i] dp i 1 mod print(sum(dp[-1]) % mod) print sum(dp[-1]) % mod sum(dp[-1]) sum dp[-1] dp -1 mod input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input l = input() input() l n = len(l) len(l) n dp = [[0, 0] for _ in range(n + 1)] [[0, 0] for _ in range(n + 1)] dp mod = 10**9 + 7 10**9 + 7 mod num = l[i - 1] l[i - 1] num
import sys
input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7
l = input()
n = len(l)
dp = [[0, 0] for _ in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    num = l[i - 1]
    if num == "1":
        dp[i][0] = dp[i - 1][0]*2
        dp[i][1] = dp[i - 1][1]*3 + dp[i - 1][0]
    else:
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][1]*3
    dp[i][0] %= mod
    dp[i][1] %= mod
print(sum(dp[-1]) % mod)