Go: package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	var nums []int
	for i := 1; i < 2*100+1; i++ {
		nums = append(nums, i*(i+1)*(i+2)/6)
	}
	var ins []int
	N := 0
	for true {
		n := sc.nextInt()
		if n == 0 {
			break
		}
		ins = append(ins, n)
		N = max(N, n)
	}
	dp := make([]int, N+1)
	dp2 := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		dp[i] = INF
		dp2[i] = INF
	}
	for i := 0; i < len(nums); i++ {
		n := nums[i]
		if n > N {
			break
		}
		for j := 0; j < N+1; j++ {
			if j >= n {
				dp[j] = min(dp[j], dp[j-n]+1)
				if n%2 != 0 {
					dp2[j] = min(dp2[j], dp2[j-n]+1)
				}
			}
		}
	}
	for i := 0; i < len(ins); i++ {
		fmt.Fprintln(wtr, dp[ins[i]], dp2[ins[i]])
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define ll long long

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}
#define OKASHI 0
#define AHO 0
#if OKASHI
// tet の要素を最小でいくつ足すと n になるか
int num_of_tet(int n, vector<int> tet){
    vector<int> min_num(n+1, -1);
    min_num[0] = 0;
    bool flag = false;
    while(min_num[n] == -1){
        vector<int> new_num(n+1, -1); // new_num[0] = 0;
        for(int i=0; i<n; i++){
            if(min_num[i] == -1) continue;
            for(int j=0; i+tet[j]<=n; j++){
                if(new_num[i+tet[j]] == -1){
                    new_num[i+tet[j]] = min_num[i]+1;
                }
                else{
                    new_num[i+tet[j]] = ((new_num[i+tet[j]] < min_num[i]+1)? new_num[i+tet[j]]:min_num[i]+1);
                }
            }
        }
        min_num = new_num;
    }

    return min_num[n];
}
#else
void num_of_tet(int n, vector<int> tet, vector<int>& res){
    #if AHO
    vector<int> min_num(n+1, -1);
    min_num[0] = 0;

    // O(n^2)
    for(int i=0; i<n; i++){
        vector<int> new_num(n+1, -1); // new_num[0] = 0;
        for(int i=0; i<n; i++){
            if(min_num[i] == -1) continue;
            for(int j=0; j<tet.size() && i+tet[j]<=n; j++){
                if(new_num[i+tet[j]] == -1){
                    new_num[i+tet[j]] = min_num[i]+1;
                }
                else{
                    new_num[i+tet[j]] = ((new_num[i+tet[j]] < min_num[i]+1)? new_num[i+tet[j]]:min_num[i]+1);
                }
            }
        }
        min_num = new_num;
    }

    res = min_num;
    #else
    // O(tet.size()*n)?
    res = vector<int>(n+1, -1);
    res[0] = 0;
    for(int i=0; i<tet.size(); i++){
        for(int j=tet[i]; j<=n; j++){
            if(res[j] == -1){
                res[j] = res[j-tet[i]] + 1;
            }
            else if(res[j] != -1 && res[j-tet[i]] != -1){
                res[j] = min(res[j], res[j-tet[i]] + 1);
            }
        }
    }
    #endif
}
#endif
signed main(){
    // cout << fixed << setprecision(10) << flush;
    int lim = 1000000;
    vector<int> tet, odd_tet;
    for(int i=1; i*(i+1)*(i+2)<=6*lim; i++){
        tet.push_back(i*(i+1)*(i+2)/6);
        if((i*(i+1)*(i+2)/6) % 2 == 1){
            odd_tet.push_back(i*(i+1)*(i+2)/6);
        }
    }

    #if OKASHI
    #else
    vector<int> res1, res2;
    num_of_tet(lim, tet, res1);
    num_of_tet(lim, odd_tet, res2);
    #endif
    int n;
    cin >> n;

    vector<int> ans1, ans2;
    while(n != 0){
        #if OKASHI
        ans1.push_back(num_of_tet(n, tet));
        ans2.push_back(num_of_tet(n, odd_tet));
        #else
        ans1.push_back(res1[n]);
        ans2.push_back(res2[n]);
        #endif
        cin >> n;
    }

    int i;
    for(i=0; i<ans1.size(); i++){
        cout << ans1[i] << " " << ans2[i] << endl;
    }

    return 0;
}