L = list(input())
N = len(L)
if '0' not in L:
    L = ['1'] + ['0']*N
    N += 1
else:
    for i in range(N):
        t = L[N-i-1]
        if t == '0':
            L[N-i-1] = '1'
            break
        else:
            L[N-i-1] = '0'
res = 0
MOD = 10**9+7
buff = 1
for d, char in enumerate(L):
    if char == '1':
        res = (res + buff * pow(3, N-1-d, MOD))%MOD
        buff = (2 * buff) % MOD
print(res)
 L = list(input()) L list(input()) list input() input N = len(L) N len(L) len L if '0' not in L:
    L = ['1'] + ['0']*N
    N += 1
else:
    for i in range(N):
        t = L[N-i-1]
        if t == '0':
            L[N-i-1] = '1'
            break
        else:
            L[N-i-1] = '0' '0' not in L '0' L L = ['1'] + ['0']*N L ['1'] + ['0']*N ['1'] '1' ['0']*N ['0'] '0' N N += 1 N 1 for i in range(N):
        t = L[N-i-1]
        if t == '0':
            L[N-i-1] = '1'
            break
        else:
            L[N-i-1] = '0' i range(N) range N t = L[N-i-1] t L[N-i-1] L N-i-1 N-i N i 1 if t == '0':
            L[N-i-1] = '1'
            break
        else:
            L[N-i-1] = '0' t == '0' t '0' L[N-i-1] = '1' L[N-i-1] L N-i-1 N-i N i 1 '1' break L[N-i-1] = '0' L[N-i-1] L N-i-1 N-i N i 1 '0' res = 0 res 0 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 buff = 1 buff 1 for d, char in enumerate(L):
    if char == '1':
        res = (res + buff * pow(3, N-1-d, MOD))%MOD
        buff = (2 * buff) % MOD d char enumerate(L) enumerate L if char == '1':
        res = (res + buff * pow(3, N-1-d, MOD))%MOD
        buff = (2 * buff) % MOD char == '1' char '1' res = (res + buff * pow(3, N-1-d, MOD))%MOD res (res + buff * pow(3, N-1-d, MOD))%MOD res + buff * pow(3, N-1-d, MOD) res buff * pow(3, N-1-d, MOD) buff pow(3, N-1-d, MOD) pow 3 N-1-d N-1 N 1 d MOD MOD buff = (2 * buff) % MOD buff (2 * buff) % MOD 2 * buff 2 buff MOD print(res) print res L = list(input()) list(input()) L MOD = 10**9+7 10**9+7 MOD res = (res + buff * pow(3, N-1-d, MOD))%MOD (res + buff * pow(3, N-1-d, MOD))%MOD res t = L[N-i-1] L[N-i-1] t N = len(L) len(L) N buff = 1 1 buff N += 1 1 N L = ['1'] + ['0']*N ['1'] + ['0']*N L res = 0 0 res buff = (2 * buff) % MOD (2 * buff) % MOD buff
L = list(input())
N = len(L)
if '0' not in L:
    L = ['1'] + ['0']*N
    N += 1
else:
    for i in range(N):
        t = L[N-i-1]
        if t == '0':
            L[N-i-1] = '1'
            break
        else:
            L[N-i-1] = '0'
res = 0
MOD = 10**9+7
buff = 1
for d, char in enumerate(L):
    if char == '1':
        res = (res + buff * pow(3, N-1-d, MOD))%MOD
        buff = (2 * buff) % MOD
print(res)

