import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    L = SI()
    n = len(L)
    b = 1
    ans = 1
    for i in range(len(L)):
        if L[n-i-1] == '1':
            ans = (ans*2 + b) % MOD
        b = (b * 3) % MOD
    print((ans)%MOD)

if __name__ == '__main__':
    main() import sys,queue,math,copy,itertools,bisect,collections,heapq sys queue math copy itertools bisect collections heapq def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    L = SI()
    n = len(L)
    b = 1
    ans = 1
    for i in range(len(L)):
        if L[n-i-1] == '1':
            ans = (ans*2 + b) % MOD
        b = (b * 3) % MOD
    print((ans)%MOD) main sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**18 INF 10**18 10 18 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda : [int(x) for x in sys.stdin.readline().split()] LI lambda : [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) NI lambda : int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline SI = lambda : sys.stdin.readline().rstrip() SI lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip L = SI() L SI() SI n = len(L) n len(L) len L b = 1 b 1 ans = 1 ans 1 for i in range(len(L)):
        if L[n-i-1] == '1':
            ans = (ans*2 + b) % MOD
        b = (b * 3) % MOD
     i range(len(L)) range len(L) len L if L[n-i-1] == '1':
            ans = (ans*2 + b) % MOD
         L[n-i-1] == '1' L[n-i-1] L n-i-1 n-i n i 1 '1' ans = (ans*2 + b) % MOD ans (ans*2 + b) % MOD ans*2 + b ans*2 ans 2 b MOD b = (b * 3) % MOD b (b * 3) % MOD b * 3 b 3 MOD print((ans)%MOD) print (ans)%MOD ans MOD if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    L = SI()
    n = len(L)
    b = 1
    ans = 1
    for i in range(len(L)):
        if L[n-i-1] == '1':
            ans = (ans*2 + b) % MOD
        b = (b * 3) % MOD
    print((ans)%MOD) def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    L = SI()
    n = len(L)
    b = 1
    ans = 1
    for i in range(len(L)):
        if L[n-i-1] == '1':
            ans = (ans*2 + b) % MOD
        b = (b * 3) % MOD
    print((ans)%MOD) main
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    L = SI()
    n = len(L)
    b = 1
    ans = 1
    for i in range(len(L)):
        if L[n-i-1] == '1':
            ans = (ans*2 + b) % MOD
        b = (b * 3) % MOD
    print((ans)%MOD)

if __name__ == '__main__':
    main()