p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p
L = input().strip()
N = len(L)
C = [0 for _ in range(N)]
for i in range(1,N):
    if L[i-1]=="1":
        C[i] = C[i-1]+1
    else:
        C[i] = C[i-1]
tot = 0
for i in range(N):
    if L[i]=="1":
        tot = (tot+pow(3,N-1-i)*pow(2,C[i]))%p
if L[N-1]=="0":
    tot = (tot+pow(2,C[N-1]))%p
else:
    tot = (tot+pow(2,C[N-1]+1))%p
print(tot) p = 10**9+7 p 10**9+7 10**9 10 9 7 def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p pow if m==0:
        return 1
     m==0 m 0 return 1 1 if m==1:
        return x
     m==1 m 1 return x x if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p m%2==0 m%2 m 2 0 return (pow(x,m//2)**2)%p (pow(x,m//2)**2)%p pow(x,m//2)**2 pow(x,m//2) pow x m//2 m 2 2 p return (x*pow(x,(m-1)//2)**2)%p (x*pow(x,(m-1)//2)**2)%p x*pow(x,(m-1)//2)**2 x pow(x,(m-1)//2)**2 pow(x,(m-1)//2) pow x (m-1)//2 m-1 m 1 2 2 p x x m m L = input().strip() L input().strip() ().strip () input strip N = len(L) N len(L) len L 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 C = [0 for _ in range(N)] C [0 for _ in range(N)] for i in range(1,N):
    if L[i-1]=="1":
        C[i] = C[i-1]+1
    else:
        C[i] = C[i-1] i range(1,N) range 1 N if L[i-1]=="1":
        C[i] = C[i-1]+1
    else:
        C[i] = C[i-1] L[i-1]=="1" L[i-1] L i-1 i 1 "1" C[i] = C[i-1]+1 C[i] C i C[i-1]+1 C[i-1] C i-1 i 1 1 C[i] = C[i-1] C[i] C i C[i-1] C i-1 i 1 tot = 0 tot 0 for i in range(N):
    if L[i]=="1":
        tot = (tot+pow(3,N-1-i)*pow(2,C[i]))%p i range(N) range N if L[i]=="1":
        tot = (tot+pow(3,N-1-i)*pow(2,C[i]))%p L[i]=="1" L[i] L i "1" tot = (tot+pow(3,N-1-i)*pow(2,C[i]))%p tot (tot+pow(3,N-1-i)*pow(2,C[i]))%p tot+pow(3,N-1-i)*pow(2,C[i]) tot pow(3,N-1-i)*pow(2,C[i]) pow(3,N-1-i) pow 3 N-1-i N-1 N 1 i pow(2,C[i]) pow 2 C[i] C i p if L[N-1]=="0":
    tot = (tot+pow(2,C[N-1]))%p
else:
    tot = (tot+pow(2,C[N-1]+1))%p L[N-1]=="0" L[N-1] L N-1 N 1 "0" tot = (tot+pow(2,C[N-1]))%p tot (tot+pow(2,C[N-1]))%p tot+pow(2,C[N-1]) tot pow(2,C[N-1]) pow 2 C[N-1] C N-1 N 1 p tot = (tot+pow(2,C[N-1]+1))%p tot (tot+pow(2,C[N-1]+1))%p tot+pow(2,C[N-1]+1) tot pow(2,C[N-1]+1) pow 2 C[N-1]+1 C[N-1] C N-1 N 1 1 p print(tot) print tot tot = (tot+pow(2,C[N-1]))%p (tot+pow(2,C[N-1]))%p tot tot = (tot+pow(2,C[N-1]+1))%p (tot+pow(2,C[N-1]+1))%p tot L = input().strip() input().strip() L p = 10**9+7 10**9+7 p tot = 0 0 tot C = [0 for _ in range(N)] [0 for _ in range(N)] C def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p pow N = len(L) len(L) N tot = (tot+pow(3,N-1-i)*pow(2,C[i]))%p (tot+pow(3,N-1-i)*pow(2,C[i]))%p tot
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p
L = input().strip()
N = len(L)
C = [0 for _ in range(N)]
for i in range(1,N):
    if L[i-1]=="1":
        C[i] = C[i-1]+1
    else:
        C[i] = C[i-1]
tot = 0
for i in range(N):
    if L[i]=="1":
        tot = (tot+pow(3,N-1-i)*pow(2,C[i]))%p
if L[N-1]=="0":
    tot = (tot+pow(2,C[N-1]))%p
else:
    tot = (tot+pow(2,C[N-1]+1))%p
print(tot)