def main():
    l = list(input())
    n = len(l)
    dp = [[0,0] for _ in range(n+1)]
    dp[0][1] = 1
    for i in range(n):
        dp[i+1][0] += dp[i][0]*3
        if l[i] == '1':
            dp[i+1][1] += dp[i][1]*2
            dp[i+1][0] += dp[i][1]
        else:
            dp[i+1][1] += dp[i][1]
        dp[i+1][0] %= 10**9+7
        dp[i+1][1] %= 10**9+7
    print(sum(dp[n])%(10**9+7))

if __name__ == "__main__":
    main() def main():
    l = list(input())
    n = len(l)
    dp = [[0,0] for _ in range(n+1)]
    dp[0][1] = 1
    for i in range(n):
        dp[i+1][0] += dp[i][0]*3
        if l[i] == '1':
            dp[i+1][1] += dp[i][1]*2
            dp[i+1][0] += dp[i][1]
        else:
            dp[i+1][1] += dp[i][1]
        dp[i+1][0] %= 10**9+7
        dp[i+1][1] %= 10**9+7
    print(sum(dp[n])%(10**9+7)) main l = list(input()) l list(input()) list input() input n = len(l) n len(l) len l [0,0] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [0,0] 0 0 dp = [[0,0] for _ in range(n+1)] dp [[0,0] for _ in range(n+1)] dp[0][1] = 1 dp[0][1] [0] dp 0 1 1 for i in range(n):
        dp[i+1][0] += dp[i][0]*3
        if l[i] == '1':
            dp[i+1][1] += dp[i][1]*2
            dp[i+1][0] += dp[i][1]
        else:
            dp[i+1][1] += dp[i][1]
        dp[i+1][0] %= 10**9+7
        dp[i+1][1] %= 10**9+7
     i range(n) range n dp[i+1][0] += dp[i][0]*3 dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0]*3 dp[i][0] [i] dp i 0 3 if l[i] == '1':
            dp[i+1][1] += dp[i][1]*2
            dp[i+1][0] += dp[i][1]
        else:
            dp[i+1][1] += dp[i][1]
         l[i] == '1' l[i] l i '1' dp[i+1][1] += dp[i][1]*2 dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1]*2 dp[i][1] [i] dp i 1 2 dp[i+1][0] += dp[i][1] dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][1] [i] dp i 1 dp[i+1][1] += dp[i][1] dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1] [i] dp i 1 dp[i+1][0] %= 10**9+7 dp[i+1][0] [i+1] dp i+1 i 1 0 10**9+7 10**9 10 9 7 dp[i+1][1] %= 10**9+7 dp[i+1][1] [i+1] dp i+1 i 1 1 10**9+7 10**9 10 9 7 print(sum(dp[n])%(10**9+7)) print sum(dp[n])%(10**9+7) sum(dp[n]) sum dp[n] dp n 10**9+7 10**9 10 9 7 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    l = list(input())
    n = len(l)
    dp = [[0,0] for _ in range(n+1)]
    dp[0][1] = 1
    for i in range(n):
        dp[i+1][0] += dp[i][0]*3
        if l[i] == '1':
            dp[i+1][1] += dp[i][1]*2
            dp[i+1][0] += dp[i][1]
        else:
            dp[i+1][1] += dp[i][1]
        dp[i+1][0] %= 10**9+7
        dp[i+1][1] %= 10**9+7
    print(sum(dp[n])%(10**9+7)) def main():
    l = list(input())
    n = len(l)
    dp = [[0,0] for _ in range(n+1)]
    dp[0][1] = 1
    for i in range(n):
        dp[i+1][0] += dp[i][0]*3
        if l[i] == '1':
            dp[i+1][1] += dp[i][1]*2
            dp[i+1][0] += dp[i][1]
        else:
            dp[i+1][1] += dp[i][1]
        dp[i+1][0] %= 10**9+7
        dp[i+1][1] %= 10**9+7
    print(sum(dp[n])%(10**9+7)) main
def main():
    l = list(input())
    n = len(l)
    dp = [[0,0] for _ in range(n+1)]
    dp[0][1] = 1
    for i in range(n):
        dp[i+1][0] += dp[i][0]*3
        if l[i] == '1':
            dp[i+1][1] += dp[i][1]*2
            dp[i+1][0] += dp[i][1]
        else:
            dp[i+1][1] += dp[i][1]
        dp[i+1][0] %= 10**9+7
        dp[i+1][1] %= 10**9+7
    print(sum(dp[n])%(10**9+7))

if __name__ == "__main__":
    main()