import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    L = SI()
    keta = len(L)

    def rec(n):
        if n == 1:
            return 3 if L[keta - n] == "1" else 1

        if L[keta - n] == "1":
            return (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD
        else:
            return rec(n-1) % MOD

    print(rec(keta))


if __name__ == "__main__":
    main() import sys sys import math math from collections import deque sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip NI = lambda: int(input()) NI lambda: int(input()) int(input()) int input() input NMI = lambda: map(int, input().split()) NMI lambda: map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split NLI = lambda: list(NMI()) NLI lambda: list(NMI()) list(NMI()) list NMI() NMI SI = lambda: input() SI lambda: input() input() input def main():
    L = SI()
    keta = len(L)

    def rec(n):
        if n == 1:
            return 3 if L[keta - n] == "1" else 1

        if L[keta - n] == "1":
            return (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD
        else:
            return rec(n-1) % MOD

    print(rec(keta)) main L = SI() L SI() SI keta = len(L) keta len(L) len L def rec(n):
        if n == 1:
            return 3 if L[keta - n] == "1" else 1

        if L[keta - n] == "1":
            return (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD
        else:
            return rec(n-1) % MOD

     rec if n == 1:
            return 3 if L[keta - n] == "1" else 1

         n == 1 n 1 return 3 if L[keta - n] == "1" else 1 3 if L[keta - n] == "1" else 1 L[keta - n] == "1" L[keta - n] L keta - n keta n "1" 3 1 if L[keta - n] == "1":
            return (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD
        else:
            return rec(n-1) % MOD

     L[keta - n] == "1" L[keta - n] L keta - n keta n "1" return (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD pow(3, (n-1), MOD) + rec(n-1) * 2 pow(3, (n-1), MOD) pow 3 n-1 n 1 MOD rec(n-1) * 2 rec(n-1) rec n-1 n 1 2 MOD return rec(n-1) % MOD rec(n-1) % MOD rec(n-1) rec n-1 n 1 MOD n n print(rec(keta)) print rec(keta) rec keta if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main NLI = lambda: list(NMI()) lambda: list(NMI()) NLI input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input NI = lambda: int(input()) lambda: int(input()) NI def main():
    L = SI()
    keta = len(L)

    def rec(n):
        if n == 1:
            return 3 if L[keta - n] == "1" else 1

        if L[keta - n] == "1":
            return (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD
        else:
            return rec(n-1) % MOD

    print(rec(keta)) def main():
    L = SI()
    keta = len(L)

    def rec(n):
        if n == 1:
            return 3 if L[keta - n] == "1" else 1

        if L[keta - n] == "1":
            return (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD
        else:
            return rec(n-1) % MOD

    print(rec(keta)) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD SI = lambda: input() lambda: input() SI NMI = lambda: map(int, input().split()) lambda: map(int, input().split()) NMI
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    L = SI()
    keta = len(L)

    def rec(n):
        if n == 1:
            return 3 if L[keta - n] == "1" else 1

        if L[keta - n] == "1":
            return (pow(3, (n-1), MOD) + rec(n-1) * 2) % MOD
        else:
            return rec(n-1) % MOD

    print(rec(keta))


if __name__ == "__main__":
    main()