MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    L = input()
    dp = [[0]*2 for _ in range(len(L) + 1)]
    
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == '1':
            dp[i + 1][0] = dp[i][0]*2
            dp[i + 1][1] = dp[i][0] + dp[i][1]*3
        else:
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]*3
        dp[i + 1][0] %= MOD
        dp[i + 1][1] %= MOD
    print(sum(dp[-1])%MOD)
if __name__ == '__main__':
    main() MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = 10 ** 11 INF 10 ** 11 10 11 import sys sys sys.setrecursionlimit(100000000) sys.setrecursionlimit sys setrecursionlimit 100000000 def main():
    L = input()
    dp = [[0]*2 for _ in range(len(L) + 1)]
    
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == '1':
            dp[i + 1][0] = dp[i][0]*2
            dp[i + 1][1] = dp[i][0] + dp[i][1]*3
        else:
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]*3
        dp[i + 1][0] %= MOD
        dp[i + 1][1] %= MOD
    print(sum(dp[-1])%MOD) main L = input() L input() input [0]*2 for _ in range(len(L) + 1) for _ in range(len(L) + 1) _ range(len(L) + 1) range len(L) + 1 len(L) len L 1 for _ in range(len(L) + 1) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(len(L) + 1)] dp [[0]*2 for _ in range(len(L) + 1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(len(L)):
        if L[i] == '1':
            dp[i + 1][0] = dp[i][0]*2
            dp[i + 1][1] = dp[i][0] + dp[i][1]*3
        else:
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]*3
        dp[i + 1][0] %= MOD
        dp[i + 1][1] %= MOD
     i range(len(L)) range len(L) len L if L[i] == '1':
            dp[i + 1][0] = dp[i][0]*2
            dp[i + 1][1] = dp[i][0] + dp[i][1]*3
        else:
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]*3
         L[i] == '1' L[i] L 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][1] = dp[i][0] + dp[i][1]*3 dp[i + 1][1] [i + 1] dp i + 1 i 1 1 dp[i][0] + dp[i][1]*3 dp[i][0] [i] dp i 0 dp[i][1]*3 dp[i][1] [i] dp i 1 3 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][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 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(sum(dp[-1])%MOD) print sum(dp[-1])%MOD sum(dp[-1]) sum dp[-1] dp -1 MOD if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    L = input()
    dp = [[0]*2 for _ in range(len(L) + 1)]
    
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == '1':
            dp[i + 1][0] = dp[i][0]*2
            dp[i + 1][1] = dp[i][0] + dp[i][1]*3
        else:
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]*3
        dp[i + 1][0] %= MOD
        dp[i + 1][1] %= MOD
    print(sum(dp[-1])%MOD) def main():
    L = input()
    dp = [[0]*2 for _ in range(len(L) + 1)]
    
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == '1':
            dp[i + 1][0] = dp[i][0]*2
            dp[i + 1][1] = dp[i][0] + dp[i][1]*3
        else:
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]*3
        dp[i + 1][0] %= MOD
        dp[i + 1][1] %= MOD
    print(sum(dp[-1])%MOD) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INF = 10 ** 11 10 ** 11 INF
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    L = input()
    dp = [[0]*2 for _ in range(len(L) + 1)]
    
    dp[0][0] = 1
    for i in range(len(L)):
        if L[i] == '1':
            dp[i + 1][0] = dp[i][0]*2
            dp[i + 1][1] = dp[i][0] + dp[i][1]*3
        else:
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]*3
        dp[i + 1][0] %= MOD
        dp[i + 1][1] %= MOD
    print(sum(dp[-1])%MOD)
if __name__ == '__main__':
    main()
