max = 0
a = []
t =Array.new(10**6+1,55)
tt =Array.new(10**6+1,50)
100.times do |n|
  max = (n*(n+1)*(n+2)/6)
  t[max] = 1
  lol = max
  next if(lol<1)
  while (lol <= 1000000)
    t[lol] = [t[lol],t[lol-max]+1].min
    lol += 1
  end
  if(max.odd?)
    tt[max] = 1
    lol = max
    while (lol <= 1000000)
      tt[lol] = [tt[lol],tt[lol-max]+1].min
      lol += 1
    end
  end
end
while ((m = gets.chomp.to_i) != 0)
  puts "#{t[m]} #{tt[m]}"
end
