MAX = 1e6.to_i

tetra = (1..1/0.0).lazy.map{ |n| n * (n + 1) * (n + 2) / 6 }.take_while{ |n| n < MAX }.to_a.reverse

def tabulate(tetra, dp)
  tetra.each do |t|
    (0...MAX - t).each do |i|
      dp[t + i] = dp[i] + 1 if dp[i] + 1 < dp[t + i]
    end
  end
end

dp = [MAX] * MAX
dp_odd = [MAX] * MAX
dp[0] = 0
dp_odd[0] = 0
tabulate(tetra, dp)
tabulate(tetra.select{ |n| n.odd? }, dp_odd)
while (n = gets.to_i) != 0
  puts [dp[n], dp_odd[n]].join(' ')
end