n = int(input()) S = set() for i in range(1, 5000): a = i*(i+1)//2 S.add(a) if n in S: print(1) exit() S = list(S) for i in range(len(S)): for j in range(len(S)): if S[i]+S[j] == n: print(2) exit() print(3)