import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


mod = 10**9 + 7


def main():
    L = in_s()
    N = len(L)

    dp1 = [0] * N
    dp2 = [0] * N

    dp1[0] = 2
    dp2[0] = 1

    for i in range(1, N):
        if L[i] == "0":
            dp1[i] = dp1[i - 1]
            dp2[i] = dp2[i - 1] * 3
        else:
            dp1[i] = dp1[i - 1] * 2
            dp2[i] = dp2[i - 1] * 3 + dp1[i - 1]
        dp1[i] %= mod
        dp2[i] %= mod

    ans = dp1[-1] + dp2[-1]
    ans %= mod

    print(ans)


if __name__ == '__main__':
    main() import sys sys 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 in_n = lambda: int(readline()) in_n lambda: int(readline()) int(readline()) int readline() readline in_nn = lambda: map(int, readline().split()) in_nn lambda: map(int, readline().split()) map(int, readline().split()) map int readline().split() ().split () readline split in_s = lambda: readline().rstrip().decode('utf-8') in_s lambda: readline().rstrip().decode('utf-8') readline().rstrip().decode('utf-8') ().rstrip().decode ().rstrip() ().rstrip () readline rstrip decode 'utf-8' in_nl = lambda: list(map(int, readline().split())) in_nl lambda: list(map(int, readline().split())) list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split in_nl() for _ in range(H) for _ in range(H) _ range(H) range H for _ in range(H) in_nl() in_nl in_nl2 = lambda H: [in_nl() for _ in range(H)] in_nl2 lambda H: [in_nl() for _ in range(H)] [in_nl() for _ in range(H)] H s == ord('.') for s in readline() if s != ord('\n') for s in readline() if s != ord('\n') s readline() readline s != ord('\n') s ord('\n') ord '\n' if s != ord('\n') s == ord('.') s ord('.') ord '.' in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')] in_map lambda: [s == ord('.') for s in readline() if s != ord('\n')] [s == ord('.') for s in readline() if s != ord('\n')] in_map() for _ in range(H) for _ in range(H) _ range(H) range H for _ in range(H) in_map() in_map in_map2 = lambda H: [in_map() for _ in range(H)] in_map2 lambda H: [in_map() for _ in range(H)] [in_map() for _ in range(H)] H in_all = lambda: map(int, read().split()) in_all lambda: map(int, read().split()) map(int, read().split()) map int read().split() ().split () read split mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 def main():
    L = in_s()
    N = len(L)

    dp1 = [0] * N
    dp2 = [0] * N

    dp1[0] = 2
    dp2[0] = 1

    for i in range(1, N):
        if L[i] == "0":
            dp1[i] = dp1[i - 1]
            dp2[i] = dp2[i - 1] * 3
        else:
            dp1[i] = dp1[i - 1] * 2
            dp2[i] = dp2[i - 1] * 3 + dp1[i - 1]
        dp1[i] %= mod
        dp2[i] %= mod

    ans = dp1[-1] + dp2[-1]
    ans %= mod

    print(ans) main L = in_s() L in_s() in_s N = len(L) N len(L) len L dp1 = [0] * N dp1 [0] * N [0] 0 N dp2 = [0] * N dp2 [0] * N [0] 0 N dp1[0] = 2 dp1[0] dp1 0 2 dp2[0] = 1 dp2[0] dp2 0 1 for i in range(1, N):
        if L[i] == "0":
            dp1[i] = dp1[i - 1]
            dp2[i] = dp2[i - 1] * 3
        else:
            dp1[i] = dp1[i - 1] * 2
            dp2[i] = dp2[i - 1] * 3 + dp1[i - 1]
        dp1[i] %= mod
        dp2[i] %= mod

     i range(1, N) range 1 N if L[i] == "0":
            dp1[i] = dp1[i - 1]
            dp2[i] = dp2[i - 1] * 3
        else:
            dp1[i] = dp1[i - 1] * 2
            dp2[i] = dp2[i - 1] * 3 + dp1[i - 1]
         L[i] == "0" L[i] L i "0" dp1[i] = dp1[i - 1] dp1[i] dp1 i dp1[i - 1] dp1 i - 1 i 1 dp2[i] = dp2[i - 1] * 3 dp2[i] dp2 i dp2[i - 1] * 3 dp2[i - 1] dp2 i - 1 i 1 3 dp1[i] = dp1[i - 1] * 2 dp1[i] dp1 i dp1[i - 1] * 2 dp1[i - 1] dp1 i - 1 i 1 2 dp2[i] = dp2[i - 1] * 3 + dp1[i - 1] dp2[i] dp2 i dp2[i - 1] * 3 + dp1[i - 1] dp2[i - 1] * 3 dp2[i - 1] dp2 i - 1 i 1 3 dp1[i - 1] dp1 i - 1 i 1 dp1[i] %= mod dp1[i] dp1 i mod dp2[i] %= mod dp2[i] dp2 i mod ans = dp1[-1] + dp2[-1] ans dp1[-1] + dp2[-1] dp1[-1] dp1 -1 dp2[-1] dp2 -1 ans %= mod ans mod print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main in_s = lambda: readline().rstrip().decode('utf-8') lambda: readline().rstrip().decode('utf-8') in_s in_nl = lambda: list(map(int, readline().split())) lambda: list(map(int, readline().split())) in_nl in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')] lambda: [s == ord('.') for s in readline() if s != ord('\n')] in_map read = sys.stdin.buffer.read sys.stdin.buffer.read read in_n = lambda: int(readline()) lambda: int(readline()) in_n readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines in_nn = lambda: map(int, readline().split()) lambda: map(int, readline().split()) in_nn in_map2 = lambda H: [in_map() for _ in range(H)] lambda H: [in_map() for _ in range(H)] in_map2 def main():
    L = in_s()
    N = len(L)

    dp1 = [0] * N
    dp2 = [0] * N

    dp1[0] = 2
    dp2[0] = 1

    for i in range(1, N):
        if L[i] == "0":
            dp1[i] = dp1[i - 1]
            dp2[i] = dp2[i - 1] * 3
        else:
            dp1[i] = dp1[i - 1] * 2
            dp2[i] = dp2[i - 1] * 3 + dp1[i - 1]
        dp1[i] %= mod
        dp2[i] %= mod

    ans = dp1[-1] + dp2[-1]
    ans %= mod

    print(ans) def main():
    L = in_s()
    N = len(L)

    dp1 = [0] * N
    dp2 = [0] * N

    dp1[0] = 2
    dp2[0] = 1

    for i in range(1, N):
        if L[i] == "0":
            dp1[i] = dp1[i - 1]
            dp2[i] = dp2[i - 1] * 3
        else:
            dp1[i] = dp1[i - 1] * 2
            dp2[i] = dp2[i - 1] * 3 + dp1[i - 1]
        dp1[i] %= mod
        dp2[i] %= mod

    ans = dp1[-1] + dp2[-1]
    ans %= mod

    print(ans) main in_all = lambda: map(int, read().split()) lambda: map(int, read().split()) in_all mod = 10**9 + 7 10**9 + 7 mod in_nl2 = lambda H: [in_nl() for _ in range(H)] lambda H: [in_nl() for _ in range(H)] in_nl2
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


mod = 10**9 + 7


def main():
    L = in_s()
    N = len(L)

    dp1 = [0] * N
    dp2 = [0] * N

    dp1[0] = 2
    dp2[0] = 1

    for i in range(1, N):
        if L[i] == "0":
            dp1[i] = dp1[i - 1]
            dp2[i] = dp2[i - 1] * 3
        else:
            dp1[i] = dp1[i - 1] * 2
            dp2[i] = dp2[i - 1] * 3 + dp1[i - 1]
        dp1[i] %= mod
        dp2[i] %= mod

    ans = dp1[-1] + dp2[-1]
    ans %= mod

    print(ans)


if __name__ == '__main__':
    main()
