import math def isTri(n): m = int(math.sqrt(2*n)) # print(str(n) + ", " + str(m) + " -> " + str(n*2) + ", " + str(m*(m+1))) # print(True if m*(m+1) == n*2 else False) return True if m*(m+1) == n*2 else False N = int(input()) if isTri(N): print(1) quit() for i in range(N+1) : x = i * (i+1) // 2 if x > N : print(3) quit() if(isTri(N - x)) : print(2) quit()