from bisect import bisect_right as br from collections import deque n = [] for i in range(1, 10000): if i*(i+1)//2>pow(10, 7): break else: n.append(i*(i+1)//2) cnt = [0]*5000 num = deque() nn = [] for i in range(len(n)): if n[i]<5000: cnt[n[i]] = 1 num.append(n[i]) nn.append(n[i]) while num: v = num.popleft() for a in nn: if v+a>=5000: break else: if cnt[v+a]==0: cnt[v+a] = cnt[v]+1 num.append(v+a) N = int(input()) if N in n: print(1) else: print(cnt[N-n[br(n, N)-1]]+1)