

"""simple docstring"""


import math





class     snake_case	:

				def __init__(	self							:				List[Any]     ,  UpperCamelCase__							:				Tuple=0)->   str:  # a graph with Node 0,1,...,N-1



						'''simple docstring'''


						__lowerCAmelCase:       Optional[int]          =			n
						__lowerCAmelCase:       Union[str, Any]          =			[
						    [math.inf for j in range(0     ,  _lowerCamelCase)] for i in range(0     ,  _lowerCamelCase)
						]  # adjacency matrix for weight
						__lowerCAmelCase:       List[Any]          =			[
						    [math.inf for j in range(0     ,  _lowerCamelCase)] for i in range(0     ,  _lowerCamelCase)
						]  # dp[i][j] stores minimum distance from i to j

				def 							lowercase_     (	self							:				str     ,  UpperCamelCase__							:				List[str]     ,  UpperCamelCase__							:				str     ,  UpperCamelCase__							:				Tuple)->   Tuple:



						'''simple docstring'''


						__lowerCAmelCase:       Tuple          =			w

				def 							lowercase_     (	self							:				Optional[int])->   Union[str, Any]:



						'''simple docstring'''


						for k in range(0     ,  self.n):
								for i in range(0     ,  self.n):
										for j in range(0     ,  self.n):
												__lowerCAmelCase:       Union[str, Any]          =			min(self.dp[i][j]     ,  self.dp[i][k] + self.dp[k][j])




				def 							lowercase_     (	self							:				Union[str, Any]     ,  UpperCamelCase__							:				Optional[Any]     ,  UpperCamelCase__							:				List[str])->   Tuple:



						'''simple docstring'''


						return self.dp[u][v]


if __name__ == "__main__":
			__A						   =			Graph(5)
			graph.add_edge(0, 2, 9)
			graph.add_edge(0, 4, 10)
			graph.add_edge(1, 3, 5)
			graph.add_edge(2, 3, 7)
			graph.add_edge(3, 0, 10)
			graph.add_edge(3, 1, 2)
			graph.add_edge(3, 2, 1)
			graph.add_edge(3, 4, 6)
			graph.add_edge(4, 1, 3)
			graph.add_edge(4, 2, 4)
			graph.add_edge(4, 3, 9)
			graph.floyd_warshall()
			graph.show_min(1, 4)
			graph.show_min(0, 3)






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())))





