### constants

MAX_N = 10 ** 6

### subroutines

def min_sums(n, thns)
  sums = (0..(n + 1)).to_a

  for thn in thns
    break if thn > n
    for i in (0..(n - thn))
      j = i + thn
      if sums[j] > sums[i] + 1
        sums[j] = sums[i] + 1
      end
    end
  end

  sums
end

### main

thns = []
othns = []

for k in (1..MAX_N)
  thn = k * (k + 1) * (k + 2) / 6
  break if thn >= MAX_N

  thns << thn
  othns << thn if thn.odd?
end
#p [thns.length, othns.length]; exit

sums = min_sums(MAX_N, thns)
osums = min_sums(MAX_N, othns)

loop do
  n = gets.to_i
  break if n == 0

  puts [sums[n], osums[n]].join(' ')
end