n = gets.not_nil!.to_i k = ((Math.sqrt(1 + 8 * n) - 1) / 2).to_i ans = 0 k.downto(1) do |i| break if n == 0 t = i * (i + 1) / 2 next if t > n c = n / t ans += c n -= c * t end p ans