import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def main():
    L = input()
    N = len(L)
    # a + b が小さいのが確定
    dp_1 = [0] * N
    # a + b が大きいのか小さいのかわからない
    dp_2 = [0] * N

    dp_1[0] = 1
    dp_2[0] = 2

    for i in range(1, N):
        if L[i] == "1":
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1] * 2

            dp_1[i] = dp_2[i - 1] + dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD
        else:
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1]

            dp_1[i] = dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD

    ans = dp_1[-1] + dp_2[-1]
    ans %= MOD
    print(ans)


if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 INF = float("inf") INF float("inf") float "inf" MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res modpow res = 1 res 1 while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
     n > 0 n 0 if n & 1:
            res = res * a % mod
         n & 1 n 1 res = res * a % mod res res * a % mod res * a res a mod a = a * a % mod a a * a % mod a * a a a mod n >>= 1 n 1 return res res a a n n mod mod def main():
    L = input()
    N = len(L)
    # a + b が小さいのが確定
    dp_1 = [0] * N
    # a + b が大きいのか小さいのかわからない
    dp_2 = [0] * N

    dp_1[0] = 1
    dp_2[0] = 2

    for i in range(1, N):
        if L[i] == "1":
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1] * 2

            dp_1[i] = dp_2[i - 1] + dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD
        else:
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1]

            dp_1[i] = dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD

    ans = dp_1[-1] + dp_2[-1]
    ans %= MOD
    print(ans) main L = input() L input() input N = len(L) N len(L) len L dp_1 = [0] * N dp_1 [0] * N [0] 0 N dp_2 = [0] * N dp_2 [0] * N [0] 0 N dp_1[0] = 1 dp_1[0] dp_1 0 1 dp_2[0] = 2 dp_2[0] dp_2 0 2 for i in range(1, N):
        if L[i] == "1":
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1] * 2

            dp_1[i] = dp_2[i - 1] + dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD
        else:
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1]

            dp_1[i] = dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD

     i range(1, N) range 1 N if L[i] == "1":
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1] * 2

            dp_1[i] = dp_2[i - 1] + dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD
        else:
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1]

            dp_1[i] = dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD

     L[i] == "1" L[i] L i "1" dp_2[i] = dp_2[i - 1] * 2 dp_2[i] dp_2 i dp_2[i - 1] * 2 dp_2[i - 1] dp_2 i - 1 i 1 2 dp_1[i] = dp_2[i - 1] + dp_1[i - 1] * 3 dp_1[i] dp_1 i dp_2[i - 1] + dp_1[i - 1] * 3 dp_2[i - 1] dp_2 i - 1 i 1 dp_1[i - 1] * 3 dp_1[i - 1] dp_1 i - 1 i 1 3 dp_2[i] %= MOD dp_2[i] dp_2 i MOD dp_1[i] %= MOD dp_1[i] dp_1 i MOD dp_2[i] = dp_2[i - 1] dp_2[i] dp_2 i dp_2[i - 1] dp_2 i - 1 i 1 dp_1[i] = dp_1[i - 1] * 3 dp_1[i] dp_1 i dp_1[i - 1] * 3 dp_1[i - 1] dp_1 i - 1 i 1 3 dp_2[i] %= MOD dp_2[i] dp_2 i MOD dp_1[i] %= MOD dp_1[i] dp_1 i MOD ans = dp_1[-1] + dp_2[-1] ans dp_1[-1] + dp_2[-1] dp_1[-1] dp_1 -1 dp_2[-1] dp_2 -1 ans %= MOD ans MOD print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INF = float("inf") float("inf") INF def main():
    L = input()
    N = len(L)
    # a + b が小さいのが確定
    dp_1 = [0] * N
    # a + b が大きいのか小さいのかわからない
    dp_2 = [0] * N

    dp_1[0] = 1
    dp_2[0] = 2

    for i in range(1, N):
        if L[i] == "1":
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1] * 2

            dp_1[i] = dp_2[i - 1] + dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD
        else:
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1]

            dp_1[i] = dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD

    ans = dp_1[-1] + dp_2[-1]
    ans %= MOD
    print(ans) def main():
    L = input()
    N = len(L)
    # a + b が小さいのが確定
    dp_1 = [0] * N
    # a + b が大きいのか小さいのかわからない
    dp_2 = [0] * N

    dp_1[0] = 1
    dp_2[0] = 2

    for i in range(1, N):
        if L[i] == "1":
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1] * 2

            dp_1[i] = dp_2[i - 1] + dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD
        else:
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1]

            dp_1[i] = dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD

    ans = dp_1[-1] + dp_2[-1]
    ans %= MOD
    print(ans) main def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res modpow def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def main():
    L = input()
    N = len(L)
    # a + b が小さいのが確定
    dp_1 = [0] * N
    # a + b が大きいのか小さいのかわからない
    dp_2 = [0] * N

    dp_1[0] = 1
    dp_2[0] = 2

    for i in range(1, N):
        if L[i] == "1":
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1] * 2

            dp_1[i] = dp_2[i - 1] + dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD
        else:
            # (1, 0), (0, 1)の組み合わせで，a+bのi桁目が1
            dp_2[i] = dp_2[i - 1]

            dp_1[i] = dp_1[i - 1] * 3

            dp_2[i] %= MOD
            dp_1[i] %= MOD

    ans = dp_1[-1] + dp_2[-1]
    ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()
