import sys
sys.setrecursionlimit(10**7)
MOD = 10**9+7
l = [int(i) for i in sys.stdin.readline().strip()]
#i番目までで決まってない時
dp0 = [0] * (len(l) + 1)
#i番目までで決まっている時
dp1 = [0] * (len(l) + 1)
dp0[0] = 1
for i, _l in enumerate(l, 1):
    if _l == 0:
        dp0[i] = dp0[i-1]
        dp1[i] = dp1[i-1] * 3
    else:
        dp0[i] = dp0[i-1] * 2
        dp1[i] = dp1[i-1] * 3 + dp0[i-1]
    dp0[i] %= MOD
    dp1[i] %= MOD
res = dp0[-1] + dp1[-1]
res %= MOD
print(res) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 int(i) for i in sys.stdin.readline().strip() for i in sys.stdin.readline().strip() i sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip for i in sys.stdin.readline().strip() int(i) int i l = [int(i) for i in sys.stdin.readline().strip()] l [int(i) for i in sys.stdin.readline().strip()] dp0 = [0] * (len(l) + 1) dp0 [0] * (len(l) + 1) [0] 0 len(l) + 1 len(l) len l 1 dp1 = [0] * (len(l) + 1) dp1 [0] * (len(l) + 1) [0] 0 len(l) + 1 len(l) len l 1 dp0[0] = 1 dp0[0] dp0 0 1 for i, _l in enumerate(l, 1):
    if _l == 0:
        dp0[i] = dp0[i-1]
        dp1[i] = dp1[i-1] * 3
    else:
        dp0[i] = dp0[i-1] * 2
        dp1[i] = dp1[i-1] * 3 + dp0[i-1]
    dp0[i] %= MOD
    dp1[i] %= MOD i _l enumerate(l, 1) enumerate l 1 if _l == 0:
        dp0[i] = dp0[i-1]
        dp1[i] = dp1[i-1] * 3
    else:
        dp0[i] = dp0[i-1] * 2
        dp1[i] = dp1[i-1] * 3 + dp0[i-1]
     _l == 0 _l 0 dp0[i] = dp0[i-1] dp0[i] dp0 i dp0[i-1] dp0 i-1 i 1 dp1[i] = dp1[i-1] * 3 dp1[i] dp1 i dp1[i-1] * 3 dp1[i-1] dp1 i-1 i 1 3 dp0[i] = dp0[i-1] * 2 dp0[i] dp0 i dp0[i-1] * 2 dp0[i-1] dp0 i-1 i 1 2 dp1[i] = dp1[i-1] * 3 + dp0[i-1] dp1[i] dp1 i dp1[i-1] * 3 + dp0[i-1] dp1[i-1] * 3 dp1[i-1] dp1 i-1 i 1 3 dp0[i-1] dp0 i-1 i 1 dp0[i] %= MOD dp0[i] dp0 i MOD dp1[i] %= MOD dp1[i] dp1 i MOD res = dp0[-1] + dp1[-1] res dp0[-1] + dp1[-1] dp0[-1] dp0 -1 dp1[-1] dp1 -1 res %= MOD res MOD print(res) print res res %= MOD MOD res l = [int(i) for i in sys.stdin.readline().strip()] [int(i) for i in sys.stdin.readline().strip()] l dp0 = [0] * (len(l) + 1) [0] * (len(l) + 1) dp0 MOD = 10**9+7 10**9+7 MOD res = dp0[-1] + dp1[-1] dp0[-1] + dp1[-1] res dp1 = [0] * (len(l) + 1) [0] * (len(l) + 1) dp1
import sys
sys.setrecursionlimit(10**7)
MOD = 10**9+7
l = [int(i) for i in sys.stdin.readline().strip()]
#i番目までで決まってない時
dp0 = [0] * (len(l) + 1)
#i番目までで決まっている時
dp1 = [0] * (len(l) + 1)
dp0[0] = 1
for i, _l in enumerate(l, 1):
    if _l == 0:
        dp0[i] = dp0[i-1]
        dp1[i] = dp1[i-1] * 3
    else:
        dp0[i] = dp0[i-1] * 2
        dp1[i] = dp1[i-1] * 3 + dp0[i-1]
    dp0[i] %= MOD
    dp1[i] %= MOD
res = dp0[-1] + dp1[-1]
res %= MOD
print(res)