


'''simple docstring'''







import os






def       lowerCAmelCase__       (				):
       _A     :	str      =					os.path.dirname(os.path.realpath(lowercase_   )   )
       _A     :	Optional[Any]      =					os.path.join(lowercase_  ,'triangle.txt'   )

       with open(lowercase_   ) as f:
              _A     :	Union[str, Any]      =					f.readlines()

       _A     :	List[str]      =					[[int(lowercase_   ) for y in x.rstrip('\r\n'   ).split(' '   )] for x in triangle]

       for i in range(1  ,len(lowercase_   )   ):
              for j in range(len(a[i]   )   ):
                     _A     :	str      =					a[i - 1][j] if j != len(a[i - 1]   ) else 0
                     _A     :	Tuple      =					a[i - 1][j - 1] if j > 0 else 0
                     a[i][j] += max(lowercase_  ,lowercase_   )
       return max(a[-1]   )


if __name__ == "__main__":
   print(solution())












'''simple docstring'''







from __future__ import annotations

_lowerCamelCase							:						Union[str, Any]								=  {1: 1}






def 		_lowercase		(	lowercase_  ):



		'''simple docstring'''







		if n in COLLATZ_SEQUENCE_LENGTHS:
				return COLLATZ_SEQUENCE_LENGTHS[n]
		_snake_case	       =       n // 2 if n % 2 == 0 else 3 * n + 1
		_snake_case	       =       collatz_sequence_length(lowercase_  ) + 1
		_snake_case	       =       sequence_length
		return sequence_length






def 		_lowercase		(	lowercase_ = 1000000  ):



		'''simple docstring'''







		_snake_case	       =       max((collatz_sequence_length(lowercase_  ), i) for i in range(1						,							lowercase_  )  )
		return result[1]


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





