import time

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K*x)%(10**9+7)
        x = (x*x)%(10**9+7)
        n //= 2

    return (K*x)%(10**9+7)

L=input()
N=len(L)


bit=[]
for i in range(0,N):
    if L[N-1-i]=='1':
        bit.append(i+1)

dp=[0 for i in range(0,100001)]

m=bit[0]
if m!=1:
    dp[m]=(2+3**(m-1))%(10**9+7)
else:
    dp[m]=3
time0=time.time()
for i in range(1,len(bit)):
    s=bit[i]
    t=bit[i-1]
    dp[s]=(2*dp[t]+pow_k(3,s-1))
time1=time.time()
print(dp[N]%(10**9+7)) import time time def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K*x)%(10**9+7)
        x = (x*x)%(10**9+7)
        n //= 2

    return (K*x)%(10**9+7) pow_k if n == 0:
        return 1

     n == 0 n 0 return 1 1 K = 1 K 1 while n > 1:
        if n % 2 != 0:
            K = (K*x)%(10**9+7)
        x = (x*x)%(10**9+7)
        n //= 2

     n > 1 n 1 if n % 2 != 0:
            K = (K*x)%(10**9+7)
         n % 2 != 0 n % 2 n 2 0 K = (K*x)%(10**9+7) K (K*x)%(10**9+7) K*x K x 10**9+7 10**9 10 9 7 x = (x*x)%(10**9+7) x (x*x)%(10**9+7) x*x x x 10**9+7 10**9 10 9 7 n //= 2 n 2 return (K*x)%(10**9+7) (K*x)%(10**9+7) K*x K x 10**9+7 10**9 10 9 7 x x n n L=input() L input() input N=len(L) N len(L) len L bit=[] bit [] for i in range(0,N):
    if L[N-1-i]=='1':
        bit.append(i+1) i range(0,N) range 0 N if L[N-1-i]=='1':
        bit.append(i+1) L[N-1-i]=='1' L[N-1-i] L N-1-i N-1 N 1 i '1' bit.append(i+1) bit.append bit append i+1 i 1 0 for i in range(0,100001) for i in range(0,100001) i range(0,100001) range 0 100001 for i in range(0,100001) 0 dp=[0 for i in range(0,100001)] dp [0 for i in range(0,100001)] m=bit[0] m bit[0] bit 0 if m!=1:
    dp[m]=(2+3**(m-1))%(10**9+7)
else:
    dp[m]=3 m!=1 m 1 dp[m]=(2+3**(m-1))%(10**9+7) dp[m] dp m (2+3**(m-1))%(10**9+7) 2+3**(m-1) 2 3**(m-1) 3 m-1 m 1 10**9+7 10**9 10 9 7 dp[m]=3 dp[m] dp m 3 time0=time.time() time0 time.time() time.time time time for i in range(1,len(bit)):
    s=bit[i]
    t=bit[i-1]
    dp[s]=(2*dp[t]+pow_k(3,s-1)) i range(1,len(bit)) range 1 len(bit) len bit s=bit[i] s bit[i] bit i t=bit[i-1] t bit[i-1] bit i-1 i 1 dp[s]=(2*dp[t]+pow_k(3,s-1)) dp[s] dp s 2*dp[t]+pow_k(3,s-1) 2*dp[t] 2 dp[t] dp t pow_k(3,s-1) pow_k 3 s-1 s 1 time1=time.time() time1 time.time() time.time time time print(dp[N]%(10**9+7)) print dp[N]%(10**9+7) dp[N] dp N 10**9+7 10**9 10 9 7 def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K*x)%(10**9+7)
        x = (x*x)%(10**9+7)
        n //= 2

    return (K*x)%(10**9+7) def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K*x)%(10**9+7)
        x = (x*x)%(10**9+7)
        n //= 2

    return (K*x)%(10**9+7) pow_k N=len(L) len(L) N time1=time.time() time.time() time1 L=input() input() L m=bit[0] bit[0] m s=bit[i] bit[i] s bit=[] [] bit t=bit[i-1] bit[i-1] t dp=[0 for i in range(0,100001)] [0 for i in range(0,100001)] dp time0=time.time() time.time() time0
import time

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K*x)%(10**9+7)
        x = (x*x)%(10**9+7)
        n //= 2

    return (K*x)%(10**9+7)

L=input()
N=len(L)


bit=[]
for i in range(0,N):
    if L[N-1-i]=='1':
        bit.append(i+1)

dp=[0 for i in range(0,100001)]

m=bit[0]
if m!=1:
    dp[m]=(2+3**(m-1))%(10**9+7)
else:
    dp[m]=3
time0=time.time()
for i in range(1,len(bit)):
    s=bit[i]
    t=bit[i-1]
    dp[s]=(2*dp[t]+pow_k(3,s-1))
time1=time.time()
print(dp[N]%(10**9+7))