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

def main():
    l = input()
    dp1 = 0
    dp2 = 1
    for i in range(len(l)):
        dp1 = 3 * dp1
        if l[i] == '0':
            dp2 = dp2
        else:
            dp1 += dp2
            dp2 = 2 * dp2
        dp1 %= MOD
        dp2 %= MOD
    print((dp1 + dp2) % MOD)

main() import sys sys sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 def main():
    l = input()
    dp1 = 0
    dp2 = 1
    for i in range(len(l)):
        dp1 = 3 * dp1
        if l[i] == '0':
            dp2 = dp2
        else:
            dp1 += dp2
            dp2 = 2 * dp2
        dp1 %= MOD
        dp2 %= MOD
    print((dp1 + dp2) % MOD) main l = input() l input() input dp1 = 0 dp1 0 dp2 = 1 dp2 1 for i in range(len(l)):
        dp1 = 3 * dp1
        if l[i] == '0':
            dp2 = dp2
        else:
            dp1 += dp2
            dp2 = 2 * dp2
        dp1 %= MOD
        dp2 %= MOD
     i range(len(l)) range len(l) len l dp1 = 3 * dp1 dp1 3 * dp1 3 dp1 if l[i] == '0':
            dp2 = dp2
        else:
            dp1 += dp2
            dp2 = 2 * dp2
         l[i] == '0' l[i] l i '0' dp2 = dp2 dp2 dp2 dp1 += dp2 dp1 dp2 dp2 = 2 * dp2 dp2 2 * dp2 2 dp2 dp1 %= MOD dp1 MOD dp2 %= MOD dp2 MOD print((dp1 + dp2) % MOD) print (dp1 + dp2) % MOD dp1 + dp2 dp1 dp2 MOD main() main def main():
    l = input()
    dp1 = 0
    dp2 = 1
    for i in range(len(l)):
        dp1 = 3 * dp1
        if l[i] == '0':
            dp2 = dp2
        else:
            dp1 += dp2
            dp2 = 2 * dp2
        dp1 %= MOD
        dp2 %= MOD
    print((dp1 + dp2) % MOD) def main():
    l = input()
    dp1 = 0
    dp2 = 1
    for i in range(len(l)):
        dp1 = 3 * dp1
        if l[i] == '0':
            dp2 = dp2
        else:
            dp1 += dp2
            dp2 = 2 * dp2
        dp1 %= MOD
        dp2 %= MOD
    print((dp1 + dp2) % MOD) main MOD = 10**9 + 7 10**9 + 7 MOD
import sys
sys.setrecursionlimit(1000000)
MOD = 10**9 + 7

def main():
    l = input()
    dp1 = 0
    dp2 = 1
    for i in range(len(l)):
        dp1 = 3 * dp1
        if l[i] == '0':
            dp2 = dp2
        else:
            dp1 += dp2
            dp2 = 2 * dp2
        dp1 %= MOD
        dp2 %= MOD
    print((dp1 + dp2) % MOD)

main()