MOD = 998244353 n = gets.to_i d = ->(n) { case n when 1 .. 9 1 when 10 .. 99 2 when 100 .. 999 3 when 1000 .. 9999 4 end } dp = [0] * n dp[0] = 1 n.times do dp2 = [0] * n (0 ... n).each do |i| (1 .. 999).each do |a| x = a - d[a] break if i < x dp2[i] += dp[i - x] end end dp = dp2.map { |x| x % MOD } end puts dp[n - 1]