def main():
    MOD = 10 ** 9 + 7
    L = input()
    N = len(L)
    dp = [0 for _ in range(N + 1)]
    dpp = [0 for _ in range(N + 1)]
    dpp[0] = 1
    for n in range(1, N + 1):
        dpp_v = dpp[n - 1]
        d = int(L[n - 1])
        dpp[n] = ((d + 1) * dpp_v) % MOD
        dp[n] = (3 * dp[n - 1] + d * dpp_v) % MOD
    print((dp[N] + dpp[N]) % MOD)


if __name__ == '__main__':
    main() def main():
    MOD = 10 ** 9 + 7
    L = input()
    N = len(L)
    dp = [0 for _ in range(N + 1)]
    dpp = [0 for _ in range(N + 1)]
    dpp[0] = 1
    for n in range(1, N + 1):
        dpp_v = dpp[n - 1]
        d = int(L[n - 1])
        dpp[n] = ((d + 1) * dpp_v) % MOD
        dp[n] = (3 * dp[n - 1] + d * dpp_v) % MOD
    print((dp[N] + dpp[N]) % MOD) main MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 L = input() L input() input N = len(L) N len(L) len L 0 for _ in range(N + 1) for _ in range(N + 1) _ range(N + 1) range N + 1 N 1 for _ in range(N + 1) 0 dp = [0 for _ in range(N + 1)] dp [0 for _ in range(N + 1)] 0 for _ in range(N + 1) for _ in range(N + 1) _ range(N + 1) range N + 1 N 1 for _ in range(N + 1) 0 dpp = [0 for _ in range(N + 1)] dpp [0 for _ in range(N + 1)] dpp[0] = 1 dpp[0] dpp 0 1 for n in range(1, N + 1):
        dpp_v = dpp[n - 1]
        d = int(L[n - 1])
        dpp[n] = ((d + 1) * dpp_v) % MOD
        dp[n] = (3 * dp[n - 1] + d * dpp_v) % MOD
     n range(1, N + 1) range 1 N + 1 N 1 dpp_v = dpp[n - 1] dpp_v dpp[n - 1] dpp n - 1 n 1 d = int(L[n - 1]) d int(L[n - 1]) int L[n - 1] L n - 1 n 1 dpp[n] = ((d + 1) * dpp_v) % MOD dpp[n] dpp n ((d + 1) * dpp_v) % MOD (d + 1) * dpp_v d + 1 d 1 dpp_v MOD dp[n] = (3 * dp[n - 1] + d * dpp_v) % MOD dp[n] dp n (3 * dp[n - 1] + d * dpp_v) % MOD 3 * dp[n - 1] + d * dpp_v 3 * dp[n - 1] 3 dp[n - 1] dp n - 1 n 1 d * dpp_v d dpp_v MOD print((dp[N] + dpp[N]) % MOD) print (dp[N] + dpp[N]) % MOD dp[N] + dpp[N] dp[N] dp N dpp[N] dpp N MOD if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    MOD = 10 ** 9 + 7
    L = input()
    N = len(L)
    dp = [0 for _ in range(N + 1)]
    dpp = [0 for _ in range(N + 1)]
    dpp[0] = 1
    for n in range(1, N + 1):
        dpp_v = dpp[n - 1]
        d = int(L[n - 1])
        dpp[n] = ((d + 1) * dpp_v) % MOD
        dp[n] = (3 * dp[n - 1] + d * dpp_v) % MOD
    print((dp[N] + dpp[N]) % MOD) def main():
    MOD = 10 ** 9 + 7
    L = input()
    N = len(L)
    dp = [0 for _ in range(N + 1)]
    dpp = [0 for _ in range(N + 1)]
    dpp[0] = 1
    for n in range(1, N + 1):
        dpp_v = dpp[n - 1]
        d = int(L[n - 1])
        dpp[n] = ((d + 1) * dpp_v) % MOD
        dp[n] = (3 * dp[n - 1] + d * dpp_v) % MOD
    print((dp[N] + dpp[N]) % MOD) main
def main():
    MOD = 10 ** 9 + 7
    L = input()
    N = len(L)
    dp = [0 for _ in range(N + 1)]
    dpp = [0 for _ in range(N + 1)]
    dpp[0] = 1
    for n in range(1, N + 1):
        dpp_v = dpp[n - 1]
        d = int(L[n - 1])
        dpp[n] = ((d + 1) * dpp_v) % MOD
        dp[n] = (3 * dp[n - 1] + d * dpp_v) % MOD
    print((dp[N] + dpp[N]) % MOD)


if __name__ == '__main__':
    main()