def z_algorithm(s) a = Array.new(s.length, 0) a[0] = s.length i = 1 j = 0 while i < s.length while i + j < s.length && s[j] == s[i + j] j += 1 end a[i] = j if j == 0 i += 1 next end k = 1 while i + k < s.length && k + a[k] < j a[i + k] = a[k] k += 1 end i += k j -= k end a end def main s = gets.strip n = s.length a = z_algorithm(s) mod = 998244353 ans = mod - n + 1 add = 10 (n - 1).downto(0) do |i| if a[i] + i >= n ans += add ans %= mod end add *= 10 add %= mod end puts ans end main if __FILE__ == $PROGRAM_NAME