import std.stdio, std.string, std.conv; import std.range, std.algorithm; void main() { int n; scan(n); int[] coin = new int[](10^^4 + 1); coin[1] = 1; foreach (i ; 2 .. 10^^4 + 1) { coin[i] = coin[i-1] + i; } int ans; while (n) { auto b = coin.assumeSorted.lowerBound(n + 1); n -= b.back; ans++; } writeln(ans); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }