def solve():
    L = input()
    N = len(L)
    mod = 10**9+7
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][1] = 1
    for i in range(1,N+1):
        if L[i-1]=='1':
            dp[i][0] = dp[i-1][0]*3+dp[i-1][1]
            dp[i][1] = dp[i-1][1]*2
        else:
            dp[i][0] = dp[i-1][0]*3
            dp[i][1] = dp[i-1][1]
        dp[i][0]%=mod
        dp[i][1]%=mod
    ans = sum(dp[-1])%mod
    return ans
print(solve()) def solve():
    L = input()
    N = len(L)
    mod = 10**9+7
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][1] = 1
    for i in range(1,N+1):
        if L[i-1]=='1':
            dp[i][0] = dp[i-1][0]*3+dp[i-1][1]
            dp[i][1] = dp[i-1][1]*2
        else:
            dp[i][0] = dp[i-1][0]*3
            dp[i][1] = dp[i-1][1]
        dp[i][0]%=mod
        dp[i][1]%=mod
    ans = sum(dp[-1])%mod
    return ans solve L = input() L input() input N = len(L) N len(L) len L mod = 10**9+7 mod 10**9+7 10**9 10 9 7 [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][1] = 1 dp[0][1] [0] dp 0 1 1 for i in range(1,N+1):
        if L[i-1]=='1':
            dp[i][0] = dp[i-1][0]*3+dp[i-1][1]
            dp[i][1] = dp[i-1][1]*2
        else:
            dp[i][0] = dp[i-1][0]*3
            dp[i][1] = dp[i-1][1]
        dp[i][0]%=mod
        dp[i][1]%=mod
     i range(1,N+1) range 1 N+1 N 1 if L[i-1]=='1':
            dp[i][0] = dp[i-1][0]*3+dp[i-1][1]
            dp[i][1] = dp[i-1][1]*2
        else:
            dp[i][0] = dp[i-1][0]*3
            dp[i][1] = dp[i-1][1]
         L[i-1]=='1' L[i-1] L i-1 i 1 '1' dp[i][0] = dp[i-1][0]*3+dp[i-1][1] dp[i][0] [i] dp i 0 dp[i-1][0]*3+dp[i-1][1] dp[i-1][0]*3 dp[i-1][0] [i-1] dp i-1 i 1 0 3 dp[i-1][1] [i-1] dp i-1 i 1 1 dp[i][1] = dp[i-1][1]*2 dp[i][1] [i] dp i 1 dp[i-1][1]*2 dp[i-1][1] [i-1] dp i-1 i 1 1 2 dp[i][0] = dp[i-1][0]*3 dp[i][0] [i] dp i 0 dp[i-1][0]*3 dp[i-1][0] [i-1] dp i-1 i 1 0 3 dp[i][1] = dp[i-1][1] dp[i][1] [i] dp i 1 dp[i-1][1] [i-1] dp i-1 i 1 1 dp[i][0]%=mod dp[i][0] [i] dp i 0 mod dp[i][1]%=mod dp[i][1] [i] dp i 1 mod ans = sum(dp[-1])%mod ans sum(dp[-1])%mod sum(dp[-1]) sum dp[-1] dp -1 mod return ans ans print(solve()) print solve() solve def solve():
    L = input()
    N = len(L)
    mod = 10**9+7
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][1] = 1
    for i in range(1,N+1):
        if L[i-1]=='1':
            dp[i][0] = dp[i-1][0]*3+dp[i-1][1]
            dp[i][1] = dp[i-1][1]*2
        else:
            dp[i][0] = dp[i-1][0]*3
            dp[i][1] = dp[i-1][1]
        dp[i][0]%=mod
        dp[i][1]%=mod
    ans = sum(dp[-1])%mod
    return ans def solve():
    L = input()
    N = len(L)
    mod = 10**9+7
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][1] = 1
    for i in range(1,N+1):
        if L[i-1]=='1':
            dp[i][0] = dp[i-1][0]*3+dp[i-1][1]
            dp[i][1] = dp[i-1][1]*2
        else:
            dp[i][0] = dp[i-1][0]*3
            dp[i][1] = dp[i-1][1]
        dp[i][0]%=mod
        dp[i][1]%=mod
    ans = sum(dp[-1])%mod
    return ans solve
def solve():
    L = input()
    N = len(L)
    mod = 10**9+7
    dp = [[0]*2 for _ in range(N+1)]
    dp[0][1] = 1
    for i in range(1,N+1):
        if L[i-1]=='1':
            dp[i][0] = dp[i-1][0]*3+dp[i-1][1]
            dp[i][1] = dp[i-1][1]*2
        else:
            dp[i][0] = dp[i-1][0]*3
            dp[i][1] = dp[i-1][1]
        dp[i][0]%=mod
        dp[i][1]%=mod
    ans = sum(dp[-1])%mod
    return ans
print(solve())