T = [i * (i + 1) // 2 for i in range(4472)] def find(i, x): low = 0 high = len(x) t = (low + high) // 2 while (low <= high): if (i == x[t]): break elif (i > x[t]): low = t + 1 elif (i < x[t]): high = t - 1 t = (low + high) // 2 return t if x[t] == i else -1 N = int(input()) if find(N, T) >= 0: print('1') exit() else: i = 0 while N - T[i] > 0: if find(N - T[i], T) >= 0: print('2') exit() i += 1 print('3')