def main():
    MOD = 10 ** 9 + 7

    EQ = 0  # 等しくなり得る
    SMALL = 1  # 未満確定

    S = map(int, input())
    dp = [1, 0]
    for x in S:
        ndp = [0] * 2

        if x == 0:
            ndp[EQ] = dp[EQ]  # (0,0)
            ndp[SMALL] = dp[SMALL] * 3  # (0,0),(0,1),(1,0)
        elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

        *dp, = map(lambda x: x % MOD, ndp)

    ans = sum(dp) % MOD  # 取り忘れ

    print(ans)


if __name__ == '__main__':
    main() def main():
    MOD = 10 ** 9 + 7

    EQ = 0  # 等しくなり得る
    SMALL = 1  # 未満確定

    S = map(int, input())
    dp = [1, 0]
    for x in S:
        ndp = [0] * 2

        if x == 0:
            ndp[EQ] = dp[EQ]  # (0,0)
            ndp[SMALL] = dp[SMALL] * 3  # (0,0),(0,1),(1,0)
        elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

        *dp, = map(lambda x: x % MOD, ndp)

    ans = sum(dp) % MOD  # 取り忘れ

    print(ans) main MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 EQ = 0 EQ 0 SMALL = 1 SMALL 1 S = map(int, input()) S map(int, input()) map int input() input dp = [1, 0] dp [1, 0] 1 0 for x in S:
        ndp = [0] * 2

        if x == 0:
            ndp[EQ] = dp[EQ]  # (0,0)
            ndp[SMALL] = dp[SMALL] * 3  # (0,0),(0,1),(1,0)
        elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

        *dp, = map(lambda x: x % MOD, ndp)

     x S ndp = [0] * 2 ndp [0] * 2 [0] 0 2 if x == 0:
            ndp[EQ] = dp[EQ]  # (0,0)
            ndp[SMALL] = dp[SMALL] * 3  # (0,0),(0,1),(1,0)
        elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

         x == 0 x 0 ndp[EQ] = dp[EQ] ndp[EQ] ndp EQ dp[EQ] dp EQ ndp[SMALL] = dp[SMALL] * 3 ndp[SMALL] ndp SMALL dp[SMALL] * 3 dp[SMALL] dp SMALL 3 elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

         x == 1 x 1 ndp[EQ] = dp[EQ] * 2 ndp[EQ] ndp EQ dp[EQ] * 2 dp[EQ] dp EQ 2 ndp[SMALL] = dp[EQ] + dp[SMALL] * 3 ndp[SMALL] ndp SMALL dp[EQ] + dp[SMALL] * 3 dp[EQ] dp EQ dp[SMALL] * 3 dp[SMALL] dp SMALL 3 *dp, = map(lambda x: x % MOD, ndp) *dp dp map(lambda x: x % MOD, ndp) map lambda x: x % MOD x % MOD x MOD x ndp ans = sum(dp) % MOD ans sum(dp) % MOD sum(dp) sum dp MOD print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    MOD = 10 ** 9 + 7

    EQ = 0  # 等しくなり得る
    SMALL = 1  # 未満確定

    S = map(int, input())
    dp = [1, 0]
    for x in S:
        ndp = [0] * 2

        if x == 0:
            ndp[EQ] = dp[EQ]  # (0,0)
            ndp[SMALL] = dp[SMALL] * 3  # (0,0),(0,1),(1,0)
        elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

        *dp, = map(lambda x: x % MOD, ndp)

    ans = sum(dp) % MOD  # 取り忘れ

    print(ans) def main():
    MOD = 10 ** 9 + 7

    EQ = 0  # 等しくなり得る
    SMALL = 1  # 未満確定

    S = map(int, input())
    dp = [1, 0]
    for x in S:
        ndp = [0] * 2

        if x == 0:
            ndp[EQ] = dp[EQ]  # (0,0)
            ndp[SMALL] = dp[SMALL] * 3  # (0,0),(0,1),(1,0)
        elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

        *dp, = map(lambda x: x % MOD, ndp)

    ans = sum(dp) % MOD  # 取り忘れ

    print(ans) main
def main():
    MOD = 10 ** 9 + 7

    EQ = 0  # 等しくなり得る
    SMALL = 1  # 未満確定

    S = map(int, input())
    dp = [1, 0]
    for x in S:
        ndp = [0] * 2

        if x == 0:
            ndp[EQ] = dp[EQ]  # (0,0)
            ndp[SMALL] = dp[SMALL] * 3  # (0,0),(0,1),(1,0)
        elif x == 1:
            ndp[EQ] = dp[EQ] * 2  # (0,1),(1,0)
            ndp[SMALL] = dp[EQ] + dp[SMALL] * 3  # EQ->(0,0), SMALL->(0,0),(0,1),(1,0)

        *dp, = map(lambda x: x % MOD, ndp)

    ans = sum(dp) % MOD  # 取り忘れ

    print(ans)


if __name__ == '__main__':
    main()
