mod = 10**9 + 7 def main(): N = input().strip() ns = [int(c) for c in N] K = len(ns) sum_less = 0 if K > 1: inv_44 = pow(44, mod-2, mod) numerator = (pow(45, K-1, mod) - 1) % mod sum_less = (45 * numerator) % mod sum_less = (sum_less * inv_44) % mod def compute_sum_k(): from collections import defaultdict dp = defaultdict(lambda: (0, 0)) # (sum, cnt) dp[(0, True, True)] = (0, 0) for pos in range(K): new_dp = defaultdict(lambda: (0, 0)) for (p, tight, lz), (sum_prev, cnt_prev) in dp.items(): if p != pos: continue current_digit = ns[pos] d_max = current_digit if tight else 9 for d in range(0, d_max + 1): new_tight = tight and (d == current_digit) new_lz = lz if lz: if d == 0: continue new_lz = False new_sum = d new_cnt = 1 else: if d == 0: continue new_sum = (sum_prev * d) % mod new_cnt = cnt_prev key = (pos + 1, new_tight, new_lz) curr_s, curr_c = new_dp[key] curr_s = (curr_s + new_sum) % mod curr_c = (curr_c + new_cnt) % mod new_dp[key] = (curr_s, curr_c) dp = new_dp sum_k = 0 for (p, tight, lz), (sum_val, _) in dp.items(): if p == K and not lz: sum_k = (sum_k + sum_val) % mod return sum_k sum_k = compute_sum_k() answer = (sum_less + sum_k) % mod print(answer) if __name__ == "__main__": main()