






from queue import PriorityQueue
from typing import Any

import numpy as np


def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		)->  float | int:





						"""simple docstring"""



						for nxt, d in graph[v]:
												if nxt in visited_forward:
																		continue
												_UpperCAmelCase									=			cst_fwd.get(__lowerCAmelCase ,		np.inf	)
												_UpperCAmelCase									=			cst_fwd[v] + d
												if new_cost_f < old_cost_f:
																		queue.put((new_cost_f, nxt)	)
																		_UpperCAmelCase									=			new_cost_f
																		_UpperCAmelCase									=			v
												if nxt in visited_backward:
																		if cst_fwd[v] + d + cst_bwd[nxt] < shortest_distance:
																								_UpperCAmelCase									=			cst_fwd[v] + d + cst_bwd[nxt]
						return shortest_distance


def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  int:





						"""simple docstring"""



						_UpperCAmelCase									=			-1

						_UpperCAmelCase									=			set()
						_UpperCAmelCase									=			set()
						_UpperCAmelCase									=			{source: 0}
						_UpperCAmelCase									=			{destination: 0}
						_UpperCAmelCase									=			{source: None}
						_UpperCAmelCase									=			{destination: None}
						_UpperCAmelCase									=			PriorityQueue()
						_UpperCAmelCase									=			PriorityQueue()

						_UpperCAmelCase									=			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():
												_UpperCAmelCase					, _UpperCAmelCase									=			queue_forward.get()
												visited_forward.add(__lowerCAmelCase	)

												_UpperCAmelCase					, _UpperCAmelCase									=			queue_backward.get()
												visited_backward.add(__lowerCAmelCase	)

												_UpperCAmelCase									=			pass_and_relaxation(
												    __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		)

												_UpperCAmelCase									=			pass_and_relaxation(
												    __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		)

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

						if shortest_distance != np.inf:
												_UpperCAmelCase									=			shortest_distance
						return shortest_path_distance


_a      	=  {
    '''B''': [['''C''', 1]],
    '''C''': [['''D''', 1]],
    '''D''': [['''F''', 1]],
    '''E''': [['''B''', 1], ['''G''', 2]],
    '''F''': [],
    '''G''': [['''F''', 1]],
}
_a      	=  {
    '''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 				__lowerCamelCase						( UpperCAmelCase_						:		int = 1000						):




      """simple docstring"""





      a							,				a						:int 							=       1, 1
      a						:Any 							=       2
      while True:
            a						:Optional[int] 							=       0
            a						:str 							=       fa + fa
            a							,				a						:List[Any] 							=       fa, f
            index += 1
            for _ in str(UpperCAmelCase_						):
                  i += 1
            if i == n:
                  break
      return index


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





