import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val max_n = 1000000

    val dp = IntArray(max_n+1)
    dp.fill(max_n, 1)
    var (i, n) = Pair(1, 1)
    while (n <= max_n) {
        for (j in n..max_n)  dp[j] = Math.min(dp[j], dp[j-n]+1)
        n = ++i*(i+1)*(i+2)/6
    }

    val dp_odd = IntArray(max_n+1)
    dp_odd.fill(max_n, 1)
    i = 1; n = 1
    while (n <= max_n) {
        if (n.and(1) == 1)  for (j in n..max_n) dp_odd[j] = Math.min(dp_odd[j], dp_odd[j-n]+1)
        n = ++i*(i+1)*(i+2) / 6
    }

    while (true) {
        val N = sc.nextInt()
        if (N == 0) break
        println("${dp[N]} ${dp_odd[N]}")
    }
}
