L=input()
#L 最大100000桁
N=len(L)
p=10**9+7
#iけた目が１
#1~N-1まで
ans1=0
for i in range(1,N):
    now=(2*pow(3, (i-1), p))%p
    ans1+=now
    ans1%=p

#Nけた目が１
dp=[0]*N
equals=[0]*N
dp[0]=0
equals[0]=2
for i in range(1,N):
    if L[i]=="0":
        equals[i]=equals[i-1]
        dp[i]=(dp[i-1]*3)%p
    else:
        equals[i]=(equals[i-1]*2)%p
        dp[i]=((dp[i-1]*3)+equals[i-1])%p

print((1+ans1+dp[-1]+equals[-1])%p)
#print(dp, equals) L=input() L input() input N=len(L) N len(L) len L p=10**9+7 p 10**9+7 10**9 10 9 7 ans1=0 ans1 0 for i in range(1,N):
    now=(2*pow(3, (i-1), p))%p
    ans1+=now
    ans1%=p

#Nけた目が１ i range(1,N) range 1 N now=(2*pow(3, (i-1), p))%p now (2*pow(3, (i-1), p))%p 2*pow(3, (i-1), p) 2 pow(3, (i-1), p) pow 3 i-1 i 1 p p ans1+=now ans1 now ans1%=p ans1 p dp=[0]*N dp [0]*N [0] 0 N equals=[0]*N equals [0]*N [0] 0 N dp[0]=0 dp[0] dp 0 0 equals[0]=2 equals[0] equals 0 2 for i in range(1,N):
    if L[i]=="0":
        equals[i]=equals[i-1]
        dp[i]=(dp[i-1]*3)%p
    else:
        equals[i]=(equals[i-1]*2)%p
        dp[i]=((dp[i-1]*3)+equals[i-1])%p i range(1,N) range 1 N if L[i]=="0":
        equals[i]=equals[i-1]
        dp[i]=(dp[i-1]*3)%p
    else:
        equals[i]=(equals[i-1]*2)%p
        dp[i]=((dp[i-1]*3)+equals[i-1])%p L[i]=="0" L[i] L i "0" equals[i]=equals[i-1] equals[i] equals i equals[i-1] equals i-1 i 1 dp[i]=(dp[i-1]*3)%p dp[i] dp i (dp[i-1]*3)%p dp[i-1]*3 dp[i-1] dp i-1 i 1 3 p equals[i]=(equals[i-1]*2)%p equals[i] equals i (equals[i-1]*2)%p equals[i-1]*2 equals[i-1] equals i-1 i 1 2 p dp[i]=((dp[i-1]*3)+equals[i-1])%p dp[i] dp i ((dp[i-1]*3)+equals[i-1])%p (dp[i-1]*3)+equals[i-1] dp[i-1]*3 dp[i-1] dp i-1 i 1 3 equals[i-1] equals i-1 i 1 p print((1+ans1+dp[-1]+equals[-1])%p) print (1+ans1+dp[-1]+equals[-1])%p 1+ans1+dp[-1]+equals[-1] 1+ans1+dp[-1] 1+ans1 1 ans1 dp[-1] dp -1 equals[-1] equals -1 p L=input() input() L p=10**9+7 10**9+7 p equals=[0]*N [0]*N equals now=(2*pow(3, (i-1), p))%p (2*pow(3, (i-1), p))%p now N=len(L) len(L) N ans1=0 0 ans1 ans1+=now now ans1 dp=[0]*N [0]*N dp ans1%=p p ans1
L=input()
#L 最大100000桁
N=len(L)
p=10**9+7
#iけた目が１
#1~N-1まで
ans1=0
for i in range(1,N):
    now=(2*pow(3, (i-1), p))%p
    ans1+=now
    ans1%=p

#Nけた目が１
dp=[0]*N
equals=[0]*N
dp[0]=0
equals[0]=2
for i in range(1,N):
    if L[i]=="0":
        equals[i]=equals[i-1]
        dp[i]=(dp[i-1]*3)%p
    else:
        equals[i]=(equals[i-1]*2)%p
        dp[i]=((dp[i-1]*3)+equals[i-1])%p

print((1+ans1+dp[-1]+equals[-1])%p)
#print(dp, equals)