def pow_mod(x, y, mod=10**9 + 7):
    if y == 0:
        return 1
    res = 1
    for i in range(y.bit_length()):
        if y & (1 << i):
            res *= x
            res %= mod
        x *= x
        x %= mod
    return res


def calc(r):
    if r <= 1:
        return 3
    return pow_mod(3, r-1) * 2

l = input()
n = len(l)
mod = 10**9 + 7

count = [0] * (n+1)
for i in range(1, n+1):
    count[i] = calc(i) + count[i-1]

ans = 0
cnt = 0
u = n
for i in range(n):
    u -= 1
    if i == n-1:
        if l[i] == "1":
            ans += 3 * pow_mod(2, cnt) % mod
            ans %= mod
        else:
            ans += pow_mod(2, cnt) % mod
            ans %= mod
        continue
    if l[i] == "1":
        # 0
        ans += count[u] % mod * pow_mod(2, cnt) % mod
        ans %= mod
        # 1
        cnt += 1
        pass
    else:
        pass

print(ans%mod)


 def pow_mod(x, y, mod=10**9 + 7):
    if y == 0:
        return 1
    res = 1
    for i in range(y.bit_length()):
        if y & (1 << i):
            res *= x
            res %= mod
        x *= x
        x %= mod
    return res pow_mod if y == 0:
        return 1
     y == 0 y 0 return 1 1 res = 1 res 1 for i in range(y.bit_length()):
        if y & (1 << i):
            res *= x
            res %= mod
        x *= x
        x %= mod
     i range(y.bit_length()) range y.bit_length() y.bit_length y bit_length if y & (1 << i):
            res *= x
            res %= mod
         y & (1 << i) y 1 << i 1 i res *= x res x res %= mod res mod x *= x x x x %= mod x mod return res res x x y y mod=10**9 + 7 mod 10**9 + 7 10**9 10 9 7 def calc(r):
    if r <= 1:
        return 3
    return pow_mod(3, r-1) * 2 calc if r <= 1:
        return 3
     r <= 1 r 1 return 3 3 return pow_mod(3, r-1) * 2 pow_mod(3, r-1) * 2 pow_mod(3, r-1) pow_mod 3 r-1 r 1 2 r r 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 count = [0] * (n+1) count [0] * (n+1) [0] 0 n+1 n 1 for i in range(1, n+1):
    count[i] = calc(i) + count[i-1] i range(1, n+1) range 1 n+1 n 1 count[i] = calc(i) + count[i-1] count[i] count i calc(i) + count[i-1] calc(i) calc i count[i-1] count i-1 i 1 ans = 0 ans 0 cnt = 0 cnt 0 u = n u n for i in range(n):
    u -= 1
    if i == n-1:
        if l[i] == "1":
            ans += 3 * pow_mod(2, cnt) % mod
            ans %= mod
        else:
            ans += pow_mod(2, cnt) % mod
            ans %= mod
        continue
    if l[i] == "1":
        # 0
        ans += count[u] % mod * pow_mod(2, cnt) % mod
        ans %= mod
        # 1
        cnt += 1
        pass
    else:
        pass i range(n) range n u -= 1 u 1 if i == n-1:
        if l[i] == "1":
            ans += 3 * pow_mod(2, cnt) % mod
            ans %= mod
        else:
            ans += pow_mod(2, cnt) % mod
            ans %= mod
        continue
     i == n-1 i n-1 n 1 if l[i] == "1":
            ans += 3 * pow_mod(2, cnt) % mod
            ans %= mod
        else:
            ans += pow_mod(2, cnt) % mod
            ans %= mod
         l[i] == "1" l[i] l i "1" ans += 3 * pow_mod(2, cnt) % mod ans 3 * pow_mod(2, cnt) % mod 3 * pow_mod(2, cnt) 3 pow_mod(2, cnt) pow_mod 2 cnt mod ans %= mod ans mod ans += pow_mod(2, cnt) % mod ans pow_mod(2, cnt) % mod pow_mod(2, cnt) pow_mod 2 cnt mod ans %= mod ans mod continue if l[i] == "1":
        # 0
        ans += count[u] % mod * pow_mod(2, cnt) % mod
        ans %= mod
        # 1
        cnt += 1
        pass
    else:
        pass l[i] == "1" l[i] l i "1" ans += count[u] % mod * pow_mod(2, cnt) % mod ans count[u] % mod * pow_mod(2, cnt) % mod count[u] % mod * pow_mod(2, cnt) count[u] % mod count[u] count u mod pow_mod(2, cnt) pow_mod 2 cnt mod ans %= mod ans mod cnt += 1 cnt 1 print(ans%mod) print ans%mod ans mod cnt += 1 1 cnt ans += 3 * pow_mod(2, cnt) % mod 3 * pow_mod(2, cnt) % mod ans ans %= mod mod ans u -= 1 1 u cnt = 0 0 cnt def calc(r):
    if r <= 1:
        return 3
    return pow_mod(3, r-1) * 2 def calc(r):
    if r <= 1:
        return 3
    return pow_mod(3, r-1) * 2 calc ans = 0 0 ans ans %= mod mod ans def pow_mod(x, y, mod=10**9 + 7):
    if y == 0:
        return 1
    res = 1
    for i in range(y.bit_length()):
        if y & (1 << i):
            res *= x
            res %= mod
        x *= x
        x %= mod
    return res def pow_mod(x, y, mod=10**9 + 7):
    if y == 0:
        return 1
    res = 1
    for i in range(y.bit_length()):
        if y & (1 << i):
            res *= x
            res %= mod
        x *= x
        x %= mod
    return res pow_mod ans += count[u] % mod * pow_mod(2, cnt) % mod count[u] % mod * pow_mod(2, cnt) % mod ans l = input() input() l mod = 10**9 + 7 10**9 + 7 mod count = [0] * (n+1) [0] * (n+1) count n = len(l) len(l) n ans += pow_mod(2, cnt) % mod pow_mod(2, cnt) % mod ans u = n n u ans %= mod mod ans
def pow_mod(x, y, mod=10**9 + 7):
    if y == 0:
        return 1
    res = 1
    for i in range(y.bit_length()):
        if y & (1 << i):
            res *= x
            res %= mod
        x *= x
        x %= mod
    return res


def calc(r):
    if r <= 1:
        return 3
    return pow_mod(3, r-1) * 2

l = input()
n = len(l)
mod = 10**9 + 7

count = [0] * (n+1)
for i in range(1, n+1):
    count[i] = calc(i) + count[i-1]

ans = 0
cnt = 0
u = n
for i in range(n):
    u -= 1
    if i == n-1:
        if l[i] == "1":
            ans += 3 * pow_mod(2, cnt) % mod
            ans %= mod
        else:
            ans += pow_mod(2, cnt) % mod
            ans %= mod
        continue
    if l[i] == "1":
        # 0
        ans += count[u] % mod * pow_mod(2, cnt) % mod
        ans %= mod
        # 1
        cnt += 1
        pass
    else:
        pass

print(ans%mod)



