import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N = I() # 三角数定理 triangle =[] for i in range(1,N+1): a = i*(i+1)//2 if a <= N: triangle.append(a) else: break for a in triangle: if a == N: print(1) exit() for a in triangle: for b in triangle: if a+b == N: print(2) exit() print(3)