### constants

INF = 1 << 30

### subroutines

def min_sums(n, ds)
  sums = (n + 1).times.map{INF}
  sums[0] = 0

  for d in ds
    for i in (0..n)
      j = i + d
      break if j > n
      if sums[j] > sums[i] + 1
        sums[j] = sums[i] + 1
      end
    end
  end

  sums[n]
end

### main

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

  thns = []
  othns = []

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

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

  puts [min_sums(n, thns), min_sums(n, othns)].join(' ')
end