output_description: Print the maximum possible sum of the digits (in base 10) of a positive
  integer not greater than N.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: # print#!/usr/bin/env python3
  # %% for atcoder uniittest use
  import sys
  
  input = lambda: sys.stdin.readline().rstrip()
  sys.setrecursionlimit(10**9)
  
  
  def pin(type=int):
      return map(type, input().split())
  
  
  def tupin(t=int):
      return tuple(pin(t))
  
  
  def lispin(t=int):
      return list(pin(t))
  
  
  # %%code
  from collections import Counter
  
  
  def resolve():
      N = list(input())
      a = sum(map(int, N))
      for n in range(1, len(N)):
          t = N[:n] + [9] * (len(N) - n)
          a = max(a, sum(map(int, t)) - 1)
      print(a)
  
  
  # %%submit!
  resolve()
  
problem_description: Statement
  
  Find the maximum possible sum of the digits (in base 10) of a positive integer
  not greater than N.
samples: [{"input": "100", "output": "18\n    \n\nFor example, the sum of the digits in 99 is 18, which turns out to be the\nmaximum value.\n\n* * *"}, {"input": "9995", "output": "35\n    \n\nFor example, the sum of the digits in 9989 is 35, which turns out to be the\nmaximum value.\n\n* * *"}, {"input": "3141592653589793", "output": "137"}]