using System; using System.Collections.Generic; using System.Linq; public class Solution { public static void Main() { var n = int.Parse(Console.ReadLine()); var tri = new List(); int i = 1; while (true) { var t = i * (i + 1) / 2; if (t <= n) { tri.Add(t); Console.Error.WriteLine(t); } else { break; } i++; } // あらゆる自然数は高々3つの三角数の和で表すことができる int count = 3; if (tri.Contains(n)) { count = 1; } else { foreach (var t in tri) { if (tri.Contains(n - t)) { count = 2; break; } } } Console.WriteLine(count); } }