import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

l=input()
# print(l)
dp1=[0]*(len(l)+1)
dp2=[0]*(len(l)+1)
dp1[0]=1
for i in range(len(l)):
    if l[i]=="1":
        dp1[i+1]+=dp1[i]*2
        dp2[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    else:
        dp1[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    dp1[i+1]%=mod
    dp2[i+1]%=mod
# print(dp1)
# print(dp2)
print((dp1[-1]+dp2[-1])%mod) import sys sys from collections import * import heapq heapq import math math import bisect bisect from itertools import permutations,accumulate,combinations,product from fractions import gcd def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 def ruiseki(lst):
    return [0]+list(accumulate(lst)) ruiseki return [0]+list(accumulate(lst)) [0]+list(accumulate(lst)) [0] 0 list(accumulate(lst)) list accumulate(lst) accumulate lst lst lst mod=pow(10,9)+7 mod pow(10,9)+7 pow(10,9) pow 10 9 7 l=input() l input() input dp1=[0]*(len(l)+1) dp1 [0]*(len(l)+1) [0] 0 len(l)+1 len(l) len l 1 dp2=[0]*(len(l)+1) dp2 [0]*(len(l)+1) [0] 0 len(l)+1 len(l) len l 1 dp1[0]=1 dp1[0] dp1 0 1 for i in range(len(l)):
    if l[i]=="1":
        dp1[i+1]+=dp1[i]*2
        dp2[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    else:
        dp1[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    dp1[i+1]%=mod
    dp2[i+1]%=mod
# print(dp1)
# print(dp2) i range(len(l)) range len(l) len l if l[i]=="1":
        dp1[i+1]+=dp1[i]*2
        dp2[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    else:
        dp1[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
     l[i]=="1" l[i] l i "1" dp1[i+1]+=dp1[i]*2 dp1[i+1] dp1 i+1 i 1 dp1[i]*2 dp1[i] dp1 i 2 dp2[i+1]+=dp1[i] dp2[i+1] dp2 i+1 i 1 dp1[i] dp1 i dp2[i+1]+=dp2[i]*3 dp2[i+1] dp2 i+1 i 1 dp2[i]*3 dp2[i] dp2 i 3 dp1[i+1]+=dp1[i] dp1[i+1] dp1 i+1 i 1 dp1[i] dp1 i dp2[i+1]+=dp2[i]*3 dp2[i+1] dp2 i+1 i 1 dp2[i]*3 dp2[i] dp2 i 3 dp1[i+1]%=mod dp1[i+1] dp1 i+1 i 1 mod dp2[i+1]%=mod dp2[i+1] dp2 i+1 i 1 mod print((dp1[-1]+dp2[-1])%mod) print (dp1[-1]+dp2[-1])%mod dp1[-1]+dp2[-1] dp1[-1] dp1 -1 dp2[-1] dp2 -1 mod dp2=[0]*(len(l)+1) [0]*(len(l)+1) dp2 mod=pow(10,9)+7 pow(10,9)+7 mod dp1=[0]*(len(l)+1) [0]*(len(l)+1) dp1 l=input() input() l def ruiseki(lst):
    return [0]+list(accumulate(lst)) def ruiseki(lst):
    return [0]+list(accumulate(lst)) ruiseki def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

l=input()
# print(l)
dp1=[0]*(len(l)+1)
dp2=[0]*(len(l)+1)
dp1[0]=1
for i in range(len(l)):
    if l[i]=="1":
        dp1[i+1]+=dp1[i]*2
        dp2[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    else:
        dp1[i+1]+=dp1[i]
        dp2[i+1]+=dp2[i]*3
    dp1[i+1]%=mod
    dp2[i+1]%=mod
# print(dp1)
# print(dp2)
print((dp1[-1]+dp2[-1])%mod)