#三角数定理、知らなかった... import bisect N = int(input()) D = [x*(x+1)//2for x in range(1, 6000)] def is_good(N): return bisect.bisect_right(D,N)!=bisect.bisect_right(D,N-1) def solve(N): if is_good(N): return 1 else: for j in range(10**4): if N>j*(j+1)//2 and is_good(N-j*(j+1)//2): return 2 return 3 print(solve(N))