import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

L = input()
N = len(L)
MOD = 10 ** 9 + 7

ans = 0

# one cnt
cnt = 0
for i in range(N):
    if L[i] == '1':
        cnt += 1
        ans += pow(3, N - i - 1, MOD) * pow(2, cnt - 1, MOD)
        ans %= MOD

ans += pow(2, cnt, MOD)
ans %= MOD

print(ans) import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines L = input() L input() input N = len(L) N len(L) len L MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 ans = 0 ans 0 cnt = 0 cnt 0 for i in range(N):
    if L[i] == '1':
        cnt += 1
        ans += pow(3, N - i - 1, MOD) * pow(2, cnt - 1, MOD)
        ans %= MOD i range(N) range N if L[i] == '1':
        cnt += 1
        ans += pow(3, N - i - 1, MOD) * pow(2, cnt - 1, MOD)
        ans %= MOD L[i] == '1' L[i] L i '1' cnt += 1 cnt 1 ans += pow(3, N - i - 1, MOD) * pow(2, cnt - 1, MOD) ans pow(3, N - i - 1, MOD) * pow(2, cnt - 1, MOD) pow(3, N - i - 1, MOD) pow 3 N - i - 1 N - i N i 1 MOD pow(2, cnt - 1, MOD) pow 2 cnt - 1 cnt 1 MOD ans %= MOD ans MOD ans += pow(2, cnt, MOD) ans pow(2, cnt, MOD) pow 2 cnt MOD ans %= MOD ans MOD print(ans) print ans cnt += 1 1 cnt ans += pow(2, cnt, MOD) pow(2, cnt, MOD) ans ans %= MOD MOD ans readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline L = input() input() L N = len(L) len(L) N readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD read = sys.stdin.buffer.read sys.stdin.buffer.read read ans %= MOD MOD ans ans += pow(3, N - i - 1, MOD) * pow(2, cnt - 1, MOD) pow(3, N - i - 1, MOD) * pow(2, cnt - 1, MOD) ans ans = 0 0 ans cnt = 0 0 cnt
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

L = input()
N = len(L)
MOD = 10 ** 9 + 7

ans = 0

# one cnt
cnt = 0
for i in range(N):
    if L[i] == '1':
        cnt += 1
        ans += pow(3, N - i - 1, MOD) * pow(2, cnt - 1, MOD)
        ans %= MOD

ans += pow(2, cnt, MOD)
ans %= MOD

print(ans)
