using System; public class Hello { public static void Main() { var c = getC(); var n = int.Parse(Console.ReadLine().Trim()); if (n == 1) { Console.WriteLine(1); goto end; } var a = getP(c, n); if (c[a] == n) { Console.WriteLine(1); goto end; } var cL = c.Length; for (int i = 0; i <= a; i++) for (int j = 0; j <= a; j++) if (c[i] + c[j] == n) { Console.WriteLine(2); goto end; } Console.WriteLine(3); end:; } public static int[] getC() { var c = new int[4471]; for (int i = 1; i <= 4471; i++) c[i - 1] = i * (i + 1) / 2; return c; } public static int getP(int[] c, int n) { var ng = 0; var ok = c.Length - 1; while (ok - ng > 1) { var mid = ng + (ok - ng) / 2; if (c[mid] >= n) ok = mid; else ng = mid; } return ok; } }