AtCoder Grand Contest 021
A
Digit Sum 2
AtCoder
⌀ 396
原题
←B →
翻译中…

Problem Statement

翻译中…

Find the maximum possible sum of the digits (in base $10$) of a positive integer not greater than $N$.

翻译中…

Constraints

翻译中…
  • $1\leq N \leq 10^{16}$
  • $N$ is an integer.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N

翻译中…

Output

翻译中…

Print the maximum possible sum of the digits (in base $10$) of a positive integer not greater than $N$.

翻译中…

样例

Input #1
100
Output #1
18
For example, the sum of the digits in $99$ is $18$, which turns out to be the maximum value.
Input #2
9995
Output #2
35
For example, the sum of the digits in $9989$ is $35$, which turns out to be the maximum value.
Input #3
3141592653589793
Output #3
137
题目信息
题号
agc021_a
时间限制
2 s
内存限制
256 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。