#%%
n = list(input())
n = n[::-1]
if n.count('1') == len(n):
    n = list('0' * len(n) + '1')
else:
    for i in range(len(n)):
        if n[i] == '0':
            n[i] = '1'
            point = i
            break
    for i in range(point):
        n[i] = '0'

n = n[::-1]
#print(n)

count = 0
ans = 0
mod = 10 ** 9 + 7

for i in range(len(n)):
    a = pow(2, count, mod)
    b = pow(3, len(n)-i-1, mod)
    if n[i] == '0':
        a, b = 0, 0 
    tmp = (a * b) % mod
    #print(a, b, tmp)
    if n[i] == '1':
        count += 1
        count %= mod
        ans += tmp
        ans %= mod

print(ans) n = list(input()) n list(input()) list input() input n = n[::-1] n n[::-1] n ::-1 -1 if n.count('1') == len(n):
    n = list('0' * len(n) + '1')
else:
    for i in range(len(n)):
        if n[i] == '0':
            n[i] = '1'
            point = i
            break
    for i in range(point):
        n[i] = '0' n.count('1') == len(n) n.count('1') n.count n count '1' len(n) len n n = list('0' * len(n) + '1') n list('0' * len(n) + '1') list '0' * len(n) + '1' '0' * len(n) '0' len(n) len n '1' for i in range(len(n)):
        if n[i] == '0':
            n[i] = '1'
            point = i
            break
     i range(len(n)) range len(n) len n if n[i] == '0':
            n[i] = '1'
            point = i
            break
     n[i] == '0' n[i] n i '0' n[i] = '1' n[i] n i '1' point = i point i break for i in range(point):
        n[i] = '0' i range(point) range point n[i] = '0' n[i] n i '0' n = n[::-1] n n[::-1] n ::-1 -1 count = 0 count 0 ans = 0 ans 0 mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 for i in range(len(n)):
    a = pow(2, count, mod)
    b = pow(3, len(n)-i-1, mod)
    if n[i] == '0':
        a, b = 0, 0 
    tmp = (a * b) % mod
    #print(a, b, tmp)
    if n[i] == '1':
        count += 1
        count %= mod
        ans += tmp
        ans %= mod i range(len(n)) range len(n) len n a = pow(2, count, mod) a pow(2, count, mod) pow 2 count mod b = pow(3, len(n)-i-1, mod) b pow(3, len(n)-i-1, mod) pow 3 len(n)-i-1 len(n)-i len(n) len n i 1 mod if n[i] == '0':
        a, b = 0, 0 
     n[i] == '0' n[i] n i '0' a, b = 0, 0 a 0 b 0 tmp = (a * b) % mod tmp (a * b) % mod a * b a b mod if n[i] == '1':
        count += 1
        count %= mod
        ans += tmp
        ans %= mod n[i] == '1' n[i] n i '1' count += 1 count 1 count %= mod count mod ans += tmp ans tmp ans %= mod ans mod print(ans) print ans tmp = (a * b) % mod (a * b) % mod tmp n = list(input()) list(input()) n point = i i point ans += tmp tmp ans n = n[::-1] n[::-1] n n = list('0' * len(n) + '1') list('0' * len(n) + '1') n b = pow(3, len(n)-i-1, mod) pow(3, len(n)-i-1, mod) b ans = 0 0 ans mod = 10 ** 9 + 7 10 ** 9 + 7 mod a, b = 0, 0 0 a n = n[::-1] n[::-1] n a = pow(2, count, mod) pow(2, count, mod) a count = 0 0 count ans %= mod mod ans count %= mod mod count b = 0, 0 0 b count += 1 1 count
#%%
n = list(input())
n = n[::-1]
if n.count('1') == len(n):
    n = list('0' * len(n) + '1')
else:
    for i in range(len(n)):
        if n[i] == '0':
            n[i] = '1'
            point = i
            break
    for i in range(point):
        n[i] = '0'

n = n[::-1]
#print(n)

count = 0
ans = 0
mod = 10 ** 9 + 7

for i in range(len(n)):
    a = pow(2, count, mod)
    b = pow(3, len(n)-i-1, mod)
    if n[i] == '0':
        a, b = 0, 0 
    tmp = (a * b) % mod
    #print(a, b, tmp)
    if n[i] == '1':
        count += 1
        count %= mod
        ans += tmp
        ans %= mod

print(ans)