def main():
    l = input()
    n = len(l)
    mod = 10**9+7
    dp1 = [0 for i in range(n)]
    dp2 = [0 for i in range(n)]
    dp1[0] = 1
    dp2[0] = 2
    for i in range(1,n):
        if l[i] == '1':
            dp2[i] = (2 * dp2[i-1])%mod
            dp1[i] = (3 * dp1[i-1] + dp2[i-1])%mod
        else:
            dp2[i] = dp2[i-1]
            dp1[i] = (3 * dp1[i-1]) % mod
    print((dp1[-1]+dp2[-1])%mod)

if __name__ == "__main__":
    main() def main():
    l = input()
    n = len(l)
    mod = 10**9+7
    dp1 = [0 for i in range(n)]
    dp2 = [0 for i in range(n)]
    dp1[0] = 1
    dp2[0] = 2
    for i in range(1,n):
        if l[i] == '1':
            dp2[i] = (2 * dp2[i-1])%mod
            dp1[i] = (3 * dp1[i-1] + dp2[i-1])%mod
        else:
            dp2[i] = dp2[i-1]
            dp1[i] = (3 * dp1[i-1]) % mod
    print((dp1[-1]+dp2[-1])%mod) main 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 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 dp1 = [0 for i in range(n)] dp1 [0 for i in range(n)] 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 dp2 = [0 for i in range(n)] dp2 [0 for i in range(n)] dp1[0] = 1 dp1[0] dp1 0 1 dp2[0] = 2 dp2[0] dp2 0 2 for i in range(1,n):
        if l[i] == '1':
            dp2[i] = (2 * dp2[i-1])%mod
            dp1[i] = (3 * dp1[i-1] + dp2[i-1])%mod
        else:
            dp2[i] = dp2[i-1]
            dp1[i] = (3 * dp1[i-1]) % mod
     i range(1,n) range 1 n if l[i] == '1':
            dp2[i] = (2 * dp2[i-1])%mod
            dp1[i] = (3 * dp1[i-1] + dp2[i-1])%mod
        else:
            dp2[i] = dp2[i-1]
            dp1[i] = (3 * dp1[i-1]) % mod
     l[i] == '1' l[i] l i '1' dp2[i] = (2 * dp2[i-1])%mod dp2[i] dp2 i (2 * dp2[i-1])%mod 2 * dp2[i-1] 2 dp2[i-1] dp2 i-1 i 1 mod dp1[i] = (3 * dp1[i-1] + dp2[i-1])%mod dp1[i] dp1 i (3 * dp1[i-1] + dp2[i-1])%mod 3 * dp1[i-1] + dp2[i-1] 3 * dp1[i-1] 3 dp1[i-1] dp1 i-1 i 1 dp2[i-1] dp2 i-1 i 1 mod dp2[i] = dp2[i-1] dp2[i] dp2 i dp2[i-1] dp2 i-1 i 1 dp1[i] = (3 * dp1[i-1]) % mod dp1[i] dp1 i (3 * dp1[i-1]) % mod 3 * dp1[i-1] 3 dp1[i-1] dp1 i-1 i 1 mod print((dp1[-1]+dp2[-1])%mod) print (dp1[-1]+dp2[-1])%mod dp1[-1]+dp2[-1] dp1[-1] dp1 -1 dp2[-1] dp2 -1 mod if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    l = input()
    n = len(l)
    mod = 10**9+7
    dp1 = [0 for i in range(n)]
    dp2 = [0 for i in range(n)]
    dp1[0] = 1
    dp2[0] = 2
    for i in range(1,n):
        if l[i] == '1':
            dp2[i] = (2 * dp2[i-1])%mod
            dp1[i] = (3 * dp1[i-1] + dp2[i-1])%mod
        else:
            dp2[i] = dp2[i-1]
            dp1[i] = (3 * dp1[i-1]) % mod
    print((dp1[-1]+dp2[-1])%mod) def main():
    l = input()
    n = len(l)
    mod = 10**9+7
    dp1 = [0 for i in range(n)]
    dp2 = [0 for i in range(n)]
    dp1[0] = 1
    dp2[0] = 2
    for i in range(1,n):
        if l[i] == '1':
            dp2[i] = (2 * dp2[i-1])%mod
            dp1[i] = (3 * dp1[i-1] + dp2[i-1])%mod
        else:
            dp2[i] = dp2[i-1]
            dp1[i] = (3 * dp1[i-1]) % mod
    print((dp1[-1]+dp2[-1])%mod) main
def main():
    l = input()
    n = len(l)
    mod = 10**9+7
    dp1 = [0 for i in range(n)]
    dp2 = [0 for i in range(n)]
    dp1[0] = 1
    dp2[0] = 2
    for i in range(1,n):
        if l[i] == '1':
            dp2[i] = (2 * dp2[i-1])%mod
            dp1[i] = (3 * dp1[i-1] + dp2[i-1])%mod
        else:
            dp2[i] = dp2[i-1]
            dp1[i] = (3 * dp1[i-1]) % mod
    print((dp1[-1]+dp2[-1])%mod)

if __name__ == "__main__":
    main()
