from sys import setrecursionlimit

setrecursionlimit(10 ** 8)

def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]

    n = len(l)

    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    answer %= MOD
    print(answer)


main() from sys import setrecursionlimit setrecursionlimit(10 ** 8) setrecursionlimit 10 ** 8 10 8 def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]

    n = len(l)

    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    answer %= MOD
    print(answer) main MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 int(char) for char in input() for char in input() char input() input for char in input() int(char) int char l = [int(char) for char in input()] l [int(char) for char in input()] n = len(l) n len(l) len l cumsum = [] cumsum [] tmp = 0 tmp 0 for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
     number l if number == 1:
            tmp += 1
         number == 1 number 1 tmp += 1 tmp 1 cumsum.append(tmp) cumsum.append cumsum append tmp pow(2, number, MOD) for number in cumsum for number in cumsum number cumsum for number in cumsum pow(2, number, MOD) pow 2 number MOD sel = [pow(2, number, MOD) for number in cumsum] sel [pow(2, number, MOD) for number in cumsum] sel.append(1) sel.append sel append 1 def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
     dp if i in _cache:
            return _cache[i]
         i in _cache i _cache return _cache[i] _cache[i] _cache i if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
         l[i] == 0 l[i] l i 0 result = dp(i-1) result dp(i-1) dp i-1 i 1 _cache[i] = result _cache[i] _cache i result return result result result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD) result dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD) dp(i-1) dp i-1 i 1 sel[i-1] * pow(3, n - 1 - i, MOD) sel[i-1] sel i-1 i 1 pow(3, n - 1 - i, MOD) pow 3 n - 1 - i n - 1 n 1 i MOD result %= MOD result MOD _cache[i] = result _cache[i] _cache i result return result result i i _cache={-1: 0} _cache {-1: 0} -1 -1 0 answer = dp(n-1) + sel[n-1] answer dp(n-1) + sel[n-1] dp(n-1) dp n-1 n 1 sel[n-1] sel n-1 n 1 answer %= MOD answer MOD print(answer) print answer main() main def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]

    n = len(l)

    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    answer %= MOD
    print(answer) def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]

    n = len(l)

    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    answer %= MOD
    print(answer) main
from sys import setrecursionlimit

setrecursionlimit(10 ** 8)

def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]

    n = len(l)

    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    answer %= MOD
    print(answer)


main()
