n=int(input()) for i in range(1,10000): if i*(i+1)//2==n: print(1) exit() for i in range(1,4000): for j in range(1,4000): if i*(i+1)//2+j*(j+1)//2==n: print(2) exit() print(3)