MOD = 10**9 + 7


def main():
    S = input()
    N = len(S)
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        # smaller: 1 -> 1
        dp[i+1][1] += dp[i][1]*3

        # smaller: 0 -> 0
        if S[i] == "1":
            dp[i+1][0] += dp[i][0]*2
        else:
            dp[i+1][0] += dp[i][0]

        # smaller: 0 -> 1
        if S[i] == "1":
            dp[i+1][1] += dp[i][0]

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

    print((dp[N][0]+dp[N][1]) % MOD)


if __name__ == '__main__':
    main() MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 def main():
    S = input()
    N = len(S)
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        # smaller: 1 -> 1
        dp[i+1][1] += dp[i][1]*3

        # smaller: 0 -> 0
        if S[i] == "1":
            dp[i+1][0] += dp[i][0]*2
        else:
            dp[i+1][0] += dp[i][0]

        # smaller: 0 -> 1
        if S[i] == "1":
            dp[i+1][1] += dp[i][0]

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

    print((dp[N][0]+dp[N][1]) % MOD) main S = input() S input() input N = len(S) N len(S) len S [0]*2 for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(N+1)] dp [[0]*2 for _ in range(N+1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(N):
        # smaller: 1 -> 1
        dp[i+1][1] += dp[i][1]*3

        # smaller: 0 -> 0
        if S[i] == "1":
            dp[i+1][0] += dp[i][0]*2
        else:
            dp[i+1][0] += dp[i][0]

        # smaller: 0 -> 1
        if S[i] == "1":
            dp[i+1][1] += dp[i][0]

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

     i range(N) range N dp[i+1][1] += dp[i][1]*3 dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1]*3 dp[i][1] [i] dp i 1 3 if S[i] == "1":
            dp[i+1][0] += dp[i][0]*2
        else:
            dp[i+1][0] += dp[i][0]

        # smaller: 0 -> 1
         S[i] == "1" S[i] S i "1" dp[i+1][0] += dp[i][0]*2 dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0]*2 dp[i][0] [i] dp i 0 2 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 if S[i] == "1":
            dp[i+1][1] += dp[i][0]

         S[i] == "1" S[i] S i "1" dp[i+1][1] += dp[i][0] dp[i+1][1] [i+1] dp i+1 i 1 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[N][0]+dp[N][1]) % MOD) print (dp[N][0]+dp[N][1]) % MOD dp[N][0]+dp[N][1] dp[N][0] [N] dp N 0 dp[N][1] [N] dp N 1 MOD if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main MOD = 10**9 + 7 10**9 + 7 MOD def main():
    S = input()
    N = len(S)
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        # smaller: 1 -> 1
        dp[i+1][1] += dp[i][1]*3

        # smaller: 0 -> 0
        if S[i] == "1":
            dp[i+1][0] += dp[i][0]*2
        else:
            dp[i+1][0] += dp[i][0]

        # smaller: 0 -> 1
        if S[i] == "1":
            dp[i+1][1] += dp[i][0]

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

    print((dp[N][0]+dp[N][1]) % MOD) def main():
    S = input()
    N = len(S)
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        # smaller: 1 -> 1
        dp[i+1][1] += dp[i][1]*3

        # smaller: 0 -> 0
        if S[i] == "1":
            dp[i+1][0] += dp[i][0]*2
        else:
            dp[i+1][0] += dp[i][0]

        # smaller: 0 -> 1
        if S[i] == "1":
            dp[i+1][1] += dp[i][0]

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

    print((dp[N][0]+dp[N][1]) % MOD) main
MOD = 10**9 + 7


def main():
    S = input()
    N = len(S)
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        # smaller: 1 -> 1
        dp[i+1][1] += dp[i][1]*3

        # smaller: 0 -> 0
        if S[i] == "1":
            dp[i+1][0] += dp[i][0]*2
        else:
            dp[i+1][0] += dp[i][0]

        # smaller: 0 -> 1
        if S[i] == "1":
            dp[i+1][1] += dp[i][0]

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

    print((dp[N][0]+dp[N][1]) % MOD)


if __name__ == '__main__':
    main()
