MOD = 10 ** 9 + 9 def f(s) l = s.size dp = Array.new(l) { Array.new(10 * l, 0) } lim = 9 * l sum = 0 l.times do |i| d = s[i].to_i if i == 0 (d - 1).downto(1) do |v| dp[i][v] += 1 end else (d - 1).downto(0) do |v| dp[i][sum + v] += 1 dp[i][sum + v] %= MOD end 1.upto(9) do |v| dp[i][v] += 1 dp[i][v] %= MOD end 0.upto(lim) do |u| 0.upto(9) do |v| next if u - v < 0 next if dp[i - 1][u - v] == 0 dp[i][u] += dp[i - 1][u - v] dp[i][u] %= MOD end end end sum += d end dp[l - 1][sum] += 1 dp[l - 1][sum] %= MOD dp[l - 1] end M, D = gets.chomp.split res1 = f(M) res2 = f(D) len = [M.size, D.size].min ans = 0 1.upto(9 * len) do |v| ans += res1[v] * res2[v] ans %= MOD end puts ans