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

def input():
    return sys.stdin.readline().rstrip()

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

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

def input():
    return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()
