





'''simple docstring'''





from queue import PriorityQueue
from typing import Any

import numpy as np




def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_ ,    lowercase_ ,    lowercase_ ,    lowercase_ ,    lowercase_ ,    lowercase_ ,    lowercase_ ,    ):




       for nxt, d in graph[v]:
              if nxt in visited_forward:
                     continue
              _lowerCamelCase							:     str	=		cst_fwd.get(__a ,    np.inf      )
              _lowerCamelCase							:     Dict	=		cst_fwd[v] + d
              if new_cost_f < old_cost_f:
                     queue.put((new_cost_f, nxt)      )
                     _lowerCamelCase							:     List[str]	=		new_cost_f
                     _lowerCamelCase							:     int	=		v
              if nxt in visited_backward:
                     if cst_fwd[v] + d + cst_bwd[nxt] < shortest_distance:
                            _lowerCamelCase							:     Tuple	=		cst_fwd[v] + d + cst_bwd[nxt]
       return shortest_distance




def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_ ,    lowercase_      ):
       _lowerCamelCase							:     Any	=		-1

       _lowerCamelCase							:     List[Any]	=		set()
       _lowerCamelCase							:     int	=		set()
       _lowerCamelCase							:     Tuple	=		{source: 0}
       _lowerCamelCase							:     Any	=		{destination: 0}
       _lowerCamelCase							:     int	=		{source: None}
       _lowerCamelCase							:     Optional[Any]	=		{destination: None}
       _lowerCamelCase							:     str	=		PriorityQueue()
       _lowerCamelCase							:     Tuple	=		PriorityQueue()

       _lowerCamelCase							:     List[str]	=		np.inf

       queue_forward.put((0, source)      )
       queue_backward.put((0, destination)      )

       if source == destination:
              return 0

       while not queue_forward.empty() and not queue_backward.empty():
              _lowerCamelCase,  _lowerCamelCase							:     Dict	=		queue_forward.get()
              visited_forward.add(__a      )

              _lowerCamelCase,  _lowerCamelCase							:     List[str]	=		queue_backward.get()
              visited_backward.add(__a      )

              _lowerCamelCase							:     List[Any]	=		pass_and_relaxation(
                  __a ,    __a ,    __a ,    __a ,    __a ,    __a ,    __a ,    __a ,    __a ,    )

              _lowerCamelCase							:     Dict	=		pass_and_relaxation(
                  __a ,    __a ,    __a ,    __a ,    __a ,    __a ,    __a ,    __a ,    __a ,    )

              if cst_fwd[v_fwd] + cst_bwd[v_bwd] >= shortest_distance:
                     break

       if shortest_distance != np.inf:
              _lowerCamelCase							:     Optional[int]	=		shortest_distance
       return shortest_path_distance


_lowerCamelCase			       =      {
    'B': [['C', 1]],
    'C': [['D', 1]],
    'D': [['F', 1]],
    'E': [['B', 1], ['G', 2]],
    'F': [],
    'G': [['F', 1]],
}
_lowerCamelCase			       =      {
    'B': [['E', 1]],
    'C': [['B', 1]],
    'D': [['C', 1]],
    'F': [['D', 1], ['G', 1]],
    'E': [[None, np.inf]],
    'G': [['E', 2]],
}

if __name__ == "__main__":
       import doctest

       doctest.testmod()








def    __UpperCAmelCase(      lowercase_ = 10_00      ):
       _lowerCamelCase							:     Optional[int]	=		2**power
       _lowerCamelCase							:     Optional[int]	=		0
       while n:
              _lowerCamelCase,  _lowerCamelCase							:     Optional[Any]	=		r + n % 10, n // 10
       return r


if __name__ == "__main__":
       print(solution(int(str(input()).strip())))

