#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;
}


Measured memory_bytes: 10516