import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) x = np.arange(1,10**4,dtype=np.int64) T = x * (x+1) // 2 is_triangle = np.zeros(10**8, np.bool_) is_triangle[T] = 1 if is_triangle[N]: print(1) else: find = False for t in T: x = N - t if x < 0: break if is_triangle[x]: find = True if find: print(2) else: print(3)