from sys import stdin
def main():
    #入力
    readline=stdin.readline
    L=readline().strip()
    n=len(L)
    mod=10**9+7

    dpF=[0]*(n+1)
    dpF[0]=1
    dpT=[0]*(n+1)
    for i in range(1,n+1):
        if L[i-1]=="1":
            dpF[i]+=2*dpF[i-1]
            dpT[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        else:
            dpF[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        dpF[i]%=mod
        dpT[i]%=mod

    print((dpF[n]+dpT[n])%mod)

if __name__=="__main__":
    main() from sys import stdin def main():
    #入力
    readline=stdin.readline
    L=readline().strip()
    n=len(L)
    mod=10**9+7

    dpF=[0]*(n+1)
    dpF[0]=1
    dpT=[0]*(n+1)
    for i in range(1,n+1):
        if L[i-1]=="1":
            dpF[i]+=2*dpF[i-1]
            dpT[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        else:
            dpF[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        dpF[i]%=mod
        dpT[i]%=mod

    print((dpF[n]+dpT[n])%mod) main readline=stdin.readline readline stdin.readline stdin readline L=readline().strip() L readline().strip() ().strip () readline strip n=len(L) n len(L) len L mod=10**9+7 mod 10**9+7 10**9 10 9 7 dpF=[0]*(n+1) dpF [0]*(n+1) [0] 0 n+1 n 1 dpF[0]=1 dpF[0] dpF 0 1 dpT=[0]*(n+1) dpT [0]*(n+1) [0] 0 n+1 n 1 for i in range(1,n+1):
        if L[i-1]=="1":
            dpF[i]+=2*dpF[i-1]
            dpT[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        else:
            dpF[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        dpF[i]%=mod
        dpT[i]%=mod

     i range(1,n+1) range 1 n+1 n 1 if L[i-1]=="1":
            dpF[i]+=2*dpF[i-1]
            dpT[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        else:
            dpF[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
         L[i-1]=="1" L[i-1] L i-1 i 1 "1" dpF[i]+=2*dpF[i-1] dpF[i] dpF i 2*dpF[i-1] 2 dpF[i-1] dpF i-1 i 1 dpT[i]+=dpF[i-1] dpT[i] dpT i dpF[i-1] dpF i-1 i 1 dpT[i]+=3*dpT[i-1] dpT[i] dpT i 3*dpT[i-1] 3 dpT[i-1] dpT i-1 i 1 dpF[i]+=dpF[i-1] dpF[i] dpF i dpF[i-1] dpF i-1 i 1 dpT[i]+=3*dpT[i-1] dpT[i] dpT i 3*dpT[i-1] 3 dpT[i-1] dpT i-1 i 1 dpF[i]%=mod dpF[i] dpF i mod dpT[i]%=mod dpT[i] dpT i mod print((dpF[n]+dpT[n])%mod) print (dpF[n]+dpT[n])%mod dpF[n]+dpT[n] dpF[n] dpF n dpT[n] dpT n mod if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def main():
    #入力
    readline=stdin.readline
    L=readline().strip()
    n=len(L)
    mod=10**9+7

    dpF=[0]*(n+1)
    dpF[0]=1
    dpT=[0]*(n+1)
    for i in range(1,n+1):
        if L[i-1]=="1":
            dpF[i]+=2*dpF[i-1]
            dpT[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        else:
            dpF[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        dpF[i]%=mod
        dpT[i]%=mod

    print((dpF[n]+dpT[n])%mod) def main():
    #入力
    readline=stdin.readline
    L=readline().strip()
    n=len(L)
    mod=10**9+7

    dpF=[0]*(n+1)
    dpF[0]=1
    dpT=[0]*(n+1)
    for i in range(1,n+1):
        if L[i-1]=="1":
            dpF[i]+=2*dpF[i-1]
            dpT[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        else:
            dpF[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        dpF[i]%=mod
        dpT[i]%=mod

    print((dpF[n]+dpT[n])%mod) main
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    L=readline().strip()
    n=len(L)
    mod=10**9+7

    dpF=[0]*(n+1)
    dpF[0]=1
    dpT=[0]*(n+1)
    for i in range(1,n+1):
        if L[i-1]=="1":
            dpF[i]+=2*dpF[i-1]
            dpT[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        else:
            dpF[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        dpF[i]%=mod
        dpT[i]%=mod

    print((dpF[n]+dpT[n])%mod)

if __name__=="__main__":
    main()