def tetras(nums)
  nums.map{ |n| n * (n + 1) * (n + 2) / 6 }.take_while{ |n| n <= 1000000 }
end

@tetra = tetras((1..200)).reverse
@tetra_odd = @tetra.select{ |t| t.odd? }

def bfs(n, tetra)
  q = []
  q << [n, 0]
  loop do
    s, c = q.shift
    return c if s == 0
    tetra.drop_while{ |t| t > s }.each do |t|
      q << [s - t, c + 1]
    end
  end
end

while (n = gets.to_i) != 0
  puts [bfs(n, @tetra), bfs(n, @tetra_odd)].join(' ')
end