#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

L=input()
n=len(L)
dp1=[0]*(n+1); dp2=[0]*(n+1)
dp2[0]=1

for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp1[i]*3 + dp2[i]) % mod
        dp2[i+1] = dp2[i]*2 % mod
    else:
        dp2[i+1] = dp2[i] % mod
        dp1[i+1] = dp1[i]*3 % mod
print((dp1[n] + dp2[n])%mod) import sys, math, itertools, collections, bisect sys math itertools collections bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') input lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.stdin.buffer.readline().rstrip().decode sys.stdin.buffer.readline().rstrip() sys.stdin.buffer.readline().rstrip sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline rstrip decode 'utf-8' inf = float('inf') inf float('inf') float 'inf' mod = 10**9+7 mod 10**9+7 10**9 10 9 7 mans = inf mans inf ans = 0 ans 0 count = 0 count 0 pro = 1 pro 1 L=input() L input() input n=len(L) n len(L) len L dp1=[0]*(n+1) dp1 [0]*(n+1) [0] 0 n+1 n 1 dp2=[0]*(n+1) dp2 [0]*(n+1) [0] 0 n+1 n 1 dp2[0]=1 dp2[0] dp2 0 1 for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp1[i]*3 + dp2[i]) % mod
        dp2[i+1] = dp2[i]*2 % mod
    else:
        dp2[i+1] = dp2[i] % mod
        dp1[i+1] = dp1[i]*3 % mod i range(n) range n if L[i] == "1":
        dp1[i+1] = (dp1[i]*3 + dp2[i]) % mod
        dp2[i+1] = dp2[i]*2 % mod
    else:
        dp2[i+1] = dp2[i] % mod
        dp1[i+1] = dp1[i]*3 % mod L[i] == "1" L[i] L i "1" dp1[i+1] = (dp1[i]*3 + dp2[i]) % mod dp1[i+1] dp1 i+1 i 1 (dp1[i]*3 + dp2[i]) % mod dp1[i]*3 + dp2[i] dp1[i]*3 dp1[i] dp1 i 3 dp2[i] dp2 i mod dp2[i+1] = dp2[i]*2 % mod dp2[i+1] dp2 i+1 i 1 dp2[i]*2 % mod dp2[i]*2 dp2[i] dp2 i 2 mod dp2[i+1] = dp2[i] % mod dp2[i+1] dp2 i+1 i 1 dp2[i] % mod dp2[i] dp2 i mod dp1[i+1] = dp1[i]*3 % mod dp1[i+1] dp1 i+1 i 1 dp1[i]*3 % mod dp1[i]*3 dp1[i] dp1 i 3 mod print((dp1[n] + dp2[n])%mod) print (dp1[n] + dp2[n])%mod dp1[n] + dp2[n] dp1[n] dp1 n dp2[n] dp2 n mod ans = 0 0 ans dp1=[0]*(n+1) [0]*(n+1) dp1 L=input() input() L dp2=[0]*(n+1) [0]*(n+1) dp2 input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') input n=len(L) len(L) n inf = float('inf') float('inf') inf count = 0 0 count mod = 10**9+7 10**9+7 mod pro = 1 1 pro mans = inf inf mans
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

L=input()
n=len(L)
dp1=[0]*(n+1); dp2=[0]*(n+1)
dp2[0]=1

for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp1[i]*3 + dp2[i]) % mod
        dp2[i+1] = dp2[i]*2 % mod
    else:
        dp2[i+1] = dp2[i] % mod
        dp1[i+1] = dp1[i]*3 % mod
print((dp1[n] + dp2[n])%mod)