MOD = 10**9 +7

def main():
    l=input()
    n=len(l)

    dp=[[0]*2 for _ in range(n)]
    dp[0][0] = 2
    dp[0][1] = 1 

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

    dp=[[0]*2 for _ in range(n)]
    dp[0][0] = 2
    dp[0][1] = 1 

    for i in range(1,n):
        if l[i]=='0':
            dp[i][0] = dp[i-1][0]
            dp[i][1] = 3*dp[i-1][1]
            dp[i][1] %= MOD
        else:
            dp[i][0] = 2*dp[i-1][0]
            dp[i][0] %= MOD
            dp[i][1] = dp[i-1][0] + 3*dp[i-1][1]
            dp[i][1] %= MOD
    
    print(sum(dp[-1])%MOD) main l=input() l input() input n=len(l) n len(l) len l [0]*2 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [0]*2 [0] 0 2 dp=[[0]*2 for _ in range(n)] dp [[0]*2 for _ in range(n)] dp[0][0] = 2 dp[0][0] [0] dp 0 0 2 dp[0][1] = 1 dp[0][1] [0] dp 0 1 1 for i in range(1,n):
        if l[i]=='0':
            dp[i][0] = dp[i-1][0]
            dp[i][1] = 3*dp[i-1][1]
            dp[i][1] %= MOD
        else:
            dp[i][0] = 2*dp[i-1][0]
            dp[i][0] %= MOD
            dp[i][1] = dp[i-1][0] + 3*dp[i-1][1]
            dp[i][1] %= MOD
    
     i range(1,n) range 1 n if l[i]=='0':
            dp[i][0] = dp[i-1][0]
            dp[i][1] = 3*dp[i-1][1]
            dp[i][1] %= MOD
        else:
            dp[i][0] = 2*dp[i-1][0]
            dp[i][0] %= MOD
            dp[i][1] = dp[i-1][0] + 3*dp[i-1][1]
            dp[i][1] %= MOD
    
     l[i]=='0' l[i] l i '0' dp[i][0] = dp[i-1][0] dp[i][0] [i] dp i 0 dp[i-1][0] [i-1] dp i-1 i 1 0 dp[i][1] = 3*dp[i-1][1] dp[i][1] [i] dp i 1 3*dp[i-1][1] 3 dp[i-1][1] [i-1] dp i-1 i 1 1 dp[i][1] %= MOD dp[i][1] [i] dp i 1 MOD dp[i][0] = 2*dp[i-1][0] dp[i][0] [i] dp i 0 2*dp[i-1][0] 2 dp[i-1][0] [i-1] dp i-1 i 1 0 dp[i][0] %= MOD dp[i][0] [i] dp i 0 MOD dp[i][1] = dp[i-1][0] + 3*dp[i-1][1] dp[i][1] [i] dp i 1 dp[i-1][0] + 3*dp[i-1][1] dp[i-1][0] [i-1] dp i-1 i 1 0 3*dp[i-1][1] 3 dp[i-1][1] [i-1] dp i-1 i 1 1 dp[i][1] %= MOD dp[i][1] [i] dp i 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()
    n=len(l)

    dp=[[0]*2 for _ in range(n)]
    dp[0][0] = 2
    dp[0][1] = 1 

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

    dp=[[0]*2 for _ in range(n)]
    dp[0][0] = 2
    dp[0][1] = 1 

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

def main():
    l=input()
    n=len(l)

    dp=[[0]*2 for _ in range(n)]
    dp[0][0] = 2
    dp[0][1] = 1 

    for i in range(1,n):
        if l[i]=='0':
            dp[i][0] = dp[i-1][0]
            dp[i][1] = 3*dp[i-1][1]
            dp[i][1] %= MOD
        else:
            dp[i][0] = 2*dp[i-1][0]
            dp[i][0] %= MOD
            dp[i][1] = dp[i-1][0] + 3*dp[i-1][1]
            dp[i][1] %= MOD
    
    print(sum(dp[-1])%MOD)
if __name__=='__main__':
    main()