def main():
    L = list(map(int,list(input())))
    MOD = 10 ** 9 + 7
    dp = [[0] * 2 for _ in range(len(L) + 5)]
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == 0:
            dp[i+1][1] = 3 * dp[i][1]
            dp[i+1][0] = dp[i][0]
        else:
            dp[i+1][0] = 2 * dp[i][0]
            dp[i+1][1] = 3 * dp[i][1] + dp[i][0]

        dp[i+1][0] %= MOD
        dp[i+1][1] %= MOD

    print((dp[len(L)][0] + dp[len(L)][1]) % MOD)


if __name__ == "__main__":
    main() def main():
    L = list(map(int,list(input())))
    MOD = 10 ** 9 + 7
    dp = [[0] * 2 for _ in range(len(L) + 5)]
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == 0:
            dp[i+1][1] = 3 * dp[i][1]
            dp[i+1][0] = dp[i][0]
        else:
            dp[i+1][0] = 2 * dp[i][0]
            dp[i+1][1] = 3 * dp[i][1] + dp[i][0]

        dp[i+1][0] %= MOD
        dp[i+1][1] %= MOD

    print((dp[len(L)][0] + dp[len(L)][1]) % MOD) main L = list(map(int,list(input()))) L list(map(int,list(input()))) list map(int,list(input())) map int list(input()) list input() input MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 [0] * 2 for _ in range(len(L) + 5) for _ in range(len(L) + 5) _ range(len(L) + 5) range len(L) + 5 len(L) len L 5 for _ in range(len(L) + 5) [0] * 2 [0] 0 2 dp = [[0] * 2 for _ in range(len(L) + 5)] dp [[0] * 2 for _ in range(len(L) + 5)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(len(L)):
        if L[i] == 0:
            dp[i+1][1] = 3 * dp[i][1]
            dp[i+1][0] = dp[i][0]
        else:
            dp[i+1][0] = 2 * dp[i][0]
            dp[i+1][1] = 3 * dp[i][1] + dp[i][0]

        dp[i+1][0] %= MOD
        dp[i+1][1] %= MOD

     i range(len(L)) range len(L) len L if L[i] == 0:
            dp[i+1][1] = 3 * dp[i][1]
            dp[i+1][0] = dp[i][0]
        else:
            dp[i+1][0] = 2 * dp[i][0]
            dp[i+1][1] = 3 * dp[i][1] + dp[i][0]

         L[i] == 0 L[i] L i 0 dp[i+1][1] = 3 * dp[i][1] dp[i+1][1] [i+1] dp i+1 i 1 1 3 * dp[i][1] 3 dp[i][1] [i] dp i 1 dp[i+1][0] = dp[i][0] dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0] [i] dp i 0 dp[i+1][0] = 2 * dp[i][0] dp[i+1][0] [i+1] dp i+1 i 1 0 2 * dp[i][0] 2 dp[i][0] [i] dp i 0 dp[i+1][1] = 3 * dp[i][1] + dp[i][0] dp[i+1][1] [i+1] dp i+1 i 1 1 3 * dp[i][1] + dp[i][0] 3 * dp[i][1] 3 dp[i][1] [i] dp i 1 dp[i][0] [i] dp i 0 dp[i+1][0] %= MOD dp[i+1][0] [i+1] dp i+1 i 1 0 MOD dp[i+1][1] %= MOD dp[i+1][1] [i+1] dp i+1 i 1 1 MOD print((dp[len(L)][0] + dp[len(L)][1]) % MOD) print (dp[len(L)][0] + dp[len(L)][1]) % MOD dp[len(L)][0] + dp[len(L)][1] dp[len(L)][0] [len(L)] dp len(L) len L 0 dp[len(L)][1] [len(L)] dp len(L) len L 1 MOD if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    L = list(map(int,list(input())))
    MOD = 10 ** 9 + 7
    dp = [[0] * 2 for _ in range(len(L) + 5)]
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == 0:
            dp[i+1][1] = 3 * dp[i][1]
            dp[i+1][0] = dp[i][0]
        else:
            dp[i+1][0] = 2 * dp[i][0]
            dp[i+1][1] = 3 * dp[i][1] + dp[i][0]

        dp[i+1][0] %= MOD
        dp[i+1][1] %= MOD

    print((dp[len(L)][0] + dp[len(L)][1]) % MOD) def main():
    L = list(map(int,list(input())))
    MOD = 10 ** 9 + 7
    dp = [[0] * 2 for _ in range(len(L) + 5)]
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == 0:
            dp[i+1][1] = 3 * dp[i][1]
            dp[i+1][0] = dp[i][0]
        else:
            dp[i+1][0] = 2 * dp[i][0]
            dp[i+1][1] = 3 * dp[i][1] + dp[i][0]

        dp[i+1][0] %= MOD
        dp[i+1][1] %= MOD

    print((dp[len(L)][0] + dp[len(L)][1]) % MOD) main
def main():
    L = list(map(int,list(input())))
    MOD = 10 ** 9 + 7
    dp = [[0] * 2 for _ in range(len(L) + 5)]
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == 0:
            dp[i+1][1] = 3 * dp[i][1]
            dp[i+1][0] = dp[i][0]
        else:
            dp[i+1][0] = 2 * dp[i][0]
            dp[i+1][1] = 3 * dp[i][1] + dp[i][0]

        dp[i+1][0] %= MOD
        dp[i+1][1] %= MOD

    print((dp[len(L)][0] + dp[len(L)][1]) % MOD)


if __name__ == "__main__":
    main()