#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(L: str):
    N = len(L)

    #dp[i][j] = i桁めまでみたとき、j=0のとき、L以下であることが確定していない、j=1確定している
    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
        if L[i] == "1":
            dp[i+1][1] += dp[i][0]
            dp[i+1][0] += dp[i][0]*2
        else: # 0
            #0のときは確定することはない
            dp[i+1][0] += dp[i][0]
        dp[i+1][0]%=MOD
        dp[i+1][1]%=MOD

    print((dp[N][0]+dp[N][1])%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)
    solve(L)

if __name__ == '__main__':
    main() import sys sys MOD = 1000000007 MOD 1000000007 def solve(L: str):
    N = len(L)

    #dp[i][j] = i桁めまでみたとき、j=0のとき、L以下であることが確定していない、j=1確定している
    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
        if L[i] == "1":
            dp[i+1][1] += dp[i][0]
            dp[i+1][0] += dp[i][0]*2
        else: # 0
            #0のときは確定することはない
            dp[i+1][0] += dp[i][0]
        dp[i+1][0]%=MOD
        dp[i+1][1]%=MOD

    print((dp[N][0]+dp[N][1])%MOD)
    return solve 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
        if L[i] == "1":
            dp[i+1][1] += dp[i][0]
            dp[i+1][0] += dp[i][0]*2
        else: # 0
            #0のときは確定することはない
            dp[i+1][0] += dp[i][0]
        dp[i+1][0]%=MOD
        dp[i+1][1]%=MOD

     i range(N) range N dp[i+1][1] += dp[i][1]*3 dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1]*3 dp[i][1] [i] dp i 1 3 if L[i] == "1":
            dp[i+1][1] += dp[i][0]
            dp[i+1][0] += dp[i][0]*2
        else: # 0
            #0のときは確定することはない
            dp[i+1][0] += dp[i][0]
         L[i] == "1" L[i] L i "1" 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]*2 dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0]*2 dp[i][0] [i] dp i 0 2 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 dp[i+1][0]%=MOD dp[i+1][0] [i+1] dp i+1 i 1 0 MOD dp[i+1][1]%=MOD dp[i+1][1] [i+1] dp i+1 i 1 1 MOD print((dp[N][0]+dp[N][1])%MOD) print (dp[N][0]+dp[N][1])%MOD dp[N][0]+dp[N][1] dp[N][0] [N] dp N 0 dp[N][1] [N] dp N 1 MOD return L: str L def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)
    solve(L) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens L = next(tokens) L next(tokens) next tokens solve(L) solve L if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def solve(L: str):
    N = len(L)

    #dp[i][j] = i桁めまでみたとき、j=0のとき、L以下であることが確定していない、j=1確定している
    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
        if L[i] == "1":
            dp[i+1][1] += dp[i][0]
            dp[i+1][0] += dp[i][0]*2
        else: # 0
            #0のときは確定することはない
            dp[i+1][0] += dp[i][0]
        dp[i+1][0]%=MOD
        dp[i+1][1]%=MOD

    print((dp[N][0]+dp[N][1])%MOD)
    return def solve(L: str):
    N = len(L)

    #dp[i][j] = i桁めまでみたとき、j=0のとき、L以下であることが確定していない、j=1確定している
    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
        if L[i] == "1":
            dp[i+1][1] += dp[i][0]
            dp[i+1][0] += dp[i][0]*2
        else: # 0
            #0のときは確定することはない
            dp[i+1][0] += dp[i][0]
        dp[i+1][0]%=MOD
        dp[i+1][1]%=MOD

    print((dp[N][0]+dp[N][1])%MOD)
    return solve def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)
    solve(L) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)
    solve(L) main MOD = 1000000007 1000000007 MOD
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(L: str):
    N = len(L)

    #dp[i][j] = i桁めまでみたとき、j=0のとき、L以下であることが確定していない、j=1確定している
    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
        if L[i] == "1":
            dp[i+1][1] += dp[i][0]
            dp[i+1][0] += dp[i][0]*2
        else: # 0
            #0のときは確定することはない
            dp[i+1][0] += dp[i][0]
        dp[i+1][0]%=MOD
        dp[i+1][1]%=MOD

    print((dp[N][0]+dp[N][1])%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = next(tokens)
    solve(L)

if __name__ == '__main__':
    main()
