MAX = 1000001
dp = Array.new(MAX, MAX)
odd_dp = Array.new(MAX, MAX)
dp[0] = odd_dp[0] = 0

for i in 1...181 do
  num = i * (i + 1) * (i + 2) / 6
  dp[num] = 1
  if num % 2 == 1
    odd_dp[num] = 1
  end
  for j in num...MAX do
    if dp[j - num] + 1 < dp[j]
      dp[j] = dp[j - num] + 1
    end
    if num % 2 == 1
      if odd_dp[j - num] + 1 < odd_dp[j]
        odd_dp[j] = odd_dp[j - num] + 1
      end
    end
  end
end

loop do
  n = gets.chomp.to_i
  if n == 0
    break
  end
  puts "#{dp[n]} #{odd_dp[n]}"
end