import sys
input = sys.stdin.readline

def main():
    MOD = 10**9+7
    L = input()
    K = len(L)-1
    
    dp1 = [0] * K
    dp1[0] = 1
    
    dp2 = [0] * K
    dp2[0] = 2
    
    for i in range(1, K):
        if L[i] == '0':
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1]
        
        else:
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1] * 2
            dp1[i] += dp2[i-1]
            
        dp1[i] %= MOD
        dp2[i] %= MOD

    print((dp1[-1]+dp2[-1])%MOD)

if __name__ == '__main__':
    main()
    import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    MOD = 10**9+7
    L = input()
    K = len(L)-1
    
    dp1 = [0] * K
    dp1[0] = 1
    
    dp2 = [0] * K
    dp2[0] = 2
    
    for i in range(1, K):
        if L[i] == '0':
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1]
        
        else:
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1] * 2
            dp1[i] += dp2[i-1]
            
        dp1[i] %= MOD
        dp2[i] %= MOD

    print((dp1[-1]+dp2[-1])%MOD) main MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 L = input() L input() input K = len(L)-1 K len(L)-1 len(L) len L 1 dp1 = [0] * K dp1 [0] * K [0] 0 K dp1[0] = 1 dp1[0] dp1 0 1 dp2 = [0] * K dp2 [0] * K [0] 0 K dp2[0] = 2 dp2[0] dp2 0 2 for i in range(1, K):
        if L[i] == '0':
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1]
        
        else:
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1] * 2
            dp1[i] += dp2[i-1]
            
        dp1[i] %= MOD
        dp2[i] %= MOD

     i range(1, K) range 1 K if L[i] == '0':
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1]
        
        else:
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1] * 2
            dp1[i] += dp2[i-1]
            
         L[i] == '0' L[i] L i '0' dp1[i] = dp1[i-1] * 3 dp1[i] dp1 i dp1[i-1] * 3 dp1[i-1] dp1 i-1 i 1 3 dp2[i] = dp2[i-1] dp2[i] dp2 i dp2[i-1] dp2 i-1 i 1 dp1[i] = dp1[i-1] * 3 dp1[i] dp1 i dp1[i-1] * 3 dp1[i-1] dp1 i-1 i 1 3 dp2[i] = dp2[i-1] * 2 dp2[i] dp2 i dp2[i-1] * 2 dp2[i-1] dp2 i-1 i 1 2 dp1[i] += dp2[i-1] dp1[i] dp1 i dp2[i-1] dp2 i-1 i 1 dp1[i] %= MOD dp1[i] dp1 i MOD dp2[i] %= MOD dp2[i] dp2 i MOD print((dp1[-1]+dp2[-1])%MOD) print (dp1[-1]+dp2[-1])%MOD dp1[-1]+dp2[-1] dp1[-1] dp1 -1 dp2[-1] dp2 -1 MOD if __name__ == '__main__':
    main()
    __name__ == '__main__' __name__ '__main__' main() main input = sys.stdin.readline sys.stdin.readline input def main():
    MOD = 10**9+7
    L = input()
    K = len(L)-1
    
    dp1 = [0] * K
    dp1[0] = 1
    
    dp2 = [0] * K
    dp2[0] = 2
    
    for i in range(1, K):
        if L[i] == '0':
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1]
        
        else:
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1] * 2
            dp1[i] += dp2[i-1]
            
        dp1[i] %= MOD
        dp2[i] %= MOD

    print((dp1[-1]+dp2[-1])%MOD) def main():
    MOD = 10**9+7
    L = input()
    K = len(L)-1
    
    dp1 = [0] * K
    dp1[0] = 1
    
    dp2 = [0] * K
    dp2[0] = 2
    
    for i in range(1, K):
        if L[i] == '0':
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1]
        
        else:
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1] * 2
            dp1[i] += dp2[i-1]
            
        dp1[i] %= MOD
        dp2[i] %= MOD

    print((dp1[-1]+dp2[-1])%MOD) main
import sys
input = sys.stdin.readline

def main():
    MOD = 10**9+7
    L = input()
    K = len(L)-1
    
    dp1 = [0] * K
    dp1[0] = 1
    
    dp2 = [0] * K
    dp2[0] = 2
    
    for i in range(1, K):
        if L[i] == '0':
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1]
        
        else:
            dp1[i] = dp1[i-1] * 3
            dp2[i] = dp2[i-1] * 2
            dp1[i] += dp2[i-1]
            
        dp1[i] %= MOD
        dp2[i] %= MOD

    print((dp1[-1]+dp2[-1])%MOD)

if __name__ == '__main__':
    main()
   