#K81652. Add One to a String-Represented Integer
Add One to a String-Represented Integer
Add One to a String-Represented Integer
You are given a non-negative integer represented as a string s. Your task is to add one to this number and output the result as a string. Importantly, if the input contains leading zeros, they must be preserved in the output, except when a carry operation increases the overall length of the number.
The problem can be summarized by the following formula in LaTeX:
\( result = s + 1 \)
Note that the operation processes the digits from right to left, propagating a carry if necessary. For example, \( 009 + 1 = 010 \) and \( 999 + 1 = 1000 \). Also, if the input string is empty, consider it as a representation of zero and output \( 1 \).
inputFormat
The input consists of a single line containing a string s which represents a non-negative integer. The string may have leading zeros and might be empty.
outputFormat
Output a single line containing the string representation of the integer that results from adding one to the input number. Leading zeros should be preserved if no carry extends the digit length.
## sample123
124