import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

l = read().rstrip().decode()
n = len(l)
mod = 10 ** 9 + 7
dp = [[0, 0] for _ in range(n)]
dp[0] = [1, 2]
for i, check in enumerate(l[1:]):
    i += 1
    dp[i][0] = dp[i - 1][0] * 3
    dp[i][1] = dp[i - 1][1]
    if check == '1':
        dp[i][0] += dp[i - 1][1]
        dp[i][1] += dp[i - 1][1]
    dp[i][0] %= mod
    dp[i][1] %= mod
print(sum(dp[-1]) % mod) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 l = read().rstrip().decode() l read().rstrip().decode() ().rstrip().decode ().rstrip() ().rstrip () read rstrip decode n = len(l) n len(l) len l mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 [0, 0] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [0, 0] 0 0 dp = [[0, 0] for _ in range(n)] dp [[0, 0] for _ in range(n)] dp[0] = [1, 2] dp[0] dp 0 [1, 2] 1 2 for i, check in enumerate(l[1:]):
    i += 1
    dp[i][0] = dp[i - 1][0] * 3
    dp[i][1] = dp[i - 1][1]
    if check == '1':
        dp[i][0] += dp[i - 1][1]
        dp[i][1] += dp[i - 1][1]
    dp[i][0] %= mod
    dp[i][1] %= mod i check enumerate(l[1:]) enumerate l[1:] l 1: 1 i += 1 i 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][1] = dp[i - 1][1] dp[i][1] [i] dp i 1 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 if check == '1':
        dp[i][0] += dp[i - 1][1]
        dp[i][1] += dp[i - 1][1]
     check == '1' check '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 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 print(sum(dp[-1]) % mod) print sum(dp[-1]) % mod sum(dp[-1]) sum dp[-1] dp -1 mod dp = [[0, 0] for _ in range(n)] [[0, 0] for _ in range(n)] dp readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline l = read().rstrip().decode() read().rstrip().decode() l read = sys.stdin.buffer.read sys.stdin.buffer.read read n = len(l) len(l) n mod = 10 ** 9 + 7 10 ** 9 + 7 mod readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines i += 1 1 i
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

l = read().rstrip().decode()
n = len(l)
mod = 10 ** 9 + 7
dp = [[0, 0] for _ in range(n)]
dp[0] = [1, 2]
for i, check in enumerate(l[1:]):
    i += 1
    dp[i][0] = dp[i - 1][0] * 3
    dp[i][1] = dp[i - 1][1]
    if check == '1':
        dp[i][0] += dp[i - 1][1]
        dp[i][1] += dp[i - 1][1]
    dp[i][0] %= mod
    dp[i][1] %= mod
print(sum(dp[-1]) % mod)
