





def  __magic_name__  (				lowercase				)				-> bool:

							"""simple docstring"""



							lowercase_	:   str  				=     (1 + 24 * n) ** 0.5
							return ((1 + root) / 6) % 1 == 0





def  __magic_name__  (				lowercase = 5000				)				-> int:

							"""simple docstring"""



							lowercase_	:   Union[str, Any]  				=     [(i * (3 * i - 1)) // 2 for i in range(1				,       lowercase				)]
							for i, pentagonal_i in enumerate(lowercase				):
														for j in range(lowercase				,       len(lowercase				)				):
																					lowercase_	:   List[Any]  				=     pentagonal_nums[j]
																					lowercase_	:   List[str]  				=     pentagonal_i + pentagonal_j
																					lowercase_	:   Optional[int]  				=     pentagonal_j - pentagonal_i
																					if is_pentagonal(lowercase				) and is_pentagonal(lowercase				):
																												return b

							return -1


if __name__ == "__main__":
							print(F'''{solution() = }''')






def  __magic_name__  (				lowercase = 1000				)				-> int:

							"""simple docstring"""



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


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