#include <iostream>
#include <algorithm> // next_permutation
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate
//#include <unordered_map> //???????????\??¢??°
#include <fstream> //ifstream, ofstream

#define NDEBUG //NDEBUG??????????????????????????´???assert?????????????????????????????????NDEBUG????????????????????¨
#include <cassert> //assert


using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
#define TEST //*******************************************************************************************************************************************
//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
//??????????????????????????????????????????????????????????§?CPU???????£??????????????????§???TLE?????????????????????????????????????????§????????¨???                           ????????????????????????cerr????????£????????????????????????????????????
#ifdef TEST
#define dout cout
#else
stringstream dummy; //???????????°??????dout?????????????????????????????????
#define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
//???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif

//?¨??????????????????????????????????????????????????????´??????OUTPUT2TEXTFILE????????????????????¬???????????????????????????????????¢????????????
//#define OUTPUT2TEXTFILE //*******************************************************************************************************************************************
#ifdef OUTPUT2TEXTFILE
#define dout outputfile //??¨????????????TLE????????§?????????dout?????¨??¨??????????????¢????????????????????????????????????????????§????¨????????????´??????????????£??????????????????????¨?????????????????????????????????????????????§?????????????????????
//TEST??????????????????????????¨???outputfile??????????????????????????????
#define OUTPUTFILENAME "output.txt"
ofstream outputfile(OUTPUTFILENAME);
#define OutputFilePath "/Users/Nag/Documents/Prgm/Test/DerivedData/Test/Build/Products/Debug/output.txt"
#endif

#define disp(A) dout << #A << " = " << (A) << endl
#define disP(A) dout << setw(3) << (A) << " " // << setw(3) ??????????????\????????????
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)

#define dispAll(A,n) dout << #A << " = "; rep(j, 0, (n)) {disP(A[j]);} dout << endl

typedef vector<int> vi;
const int INF = 1e9-1;


int tetrahedral(int n) {
    assert( (n*(n+1)*(n+2)) % 6 == 0);
    return n*(n+1)*(n+2)/6;
}

int tetrahedralOdd(int n) {
    n = n*4-3;
    assert( (n*(n+1)*(n+2)) % 6 == 0);
    return n*(n+1)*(n+2)/6;
}

int iMaxForTetrahedral(int x) { //?????¶??°x??\???????????§?????£?????¢?????°???i?????????
    assert(x>0);
    
    int i = 1;
    while(tetrahedral(i)<=x) i++;
    
    return --i;
}

int iMaxForTetrahedralOdd(int x) { //?????¶??°x??\???????????§????\???°??£?????¢?????°???i?????????
    assert(x>0);
    
    int i = 1;
    while(tetrahedralOdd(i)<=x) i++;
    
    return --i;
}



int main(){
    
    int N; //??£?????¢?????°????????????????????????????????????????????°
    
    while(1) {
        cin >> N;
        if(N==0) break;
        
        vi T;
        T.push_back(0); //T[0] = 0
        rep(i,1,N+1) T.push_back(INF); //T[1] ... T[N] = INF
        
        rep(i, 1, iMaxForTetrahedral(N)+1 ) {
            rep(j, tetrahedral(i), N+1) {
                T[j] = min( T[j], T[j-tetrahedral(i)] + 1 );
                
//                disp(i);
//                disp(j);
//                
//                disp(tetrahedral(i));
//                
//                
//                dout<<"N = ";
//                rep(i,0,N+1) disP(i);
//                dout<<endl;
//                dispAll(T, N+1);
//                dout<<"----------T\n";
            }
        }
        
        
        
        
        vi S;
        S.push_back(0); //S[0] = 0
        rep(i,1,N+1) S.push_back(INF); //S[1] ... S[N] = INF
        
        rep(i, 1, iMaxForTetrahedralOdd(N)+1 ) {
            rep(j, tetrahedralOdd(i), N+1) {
                S[j] = min( S[j], S[j-tetrahedralOdd(i)] + 1 );
                
//                disp(i);
//                disp(j);
//                
//                dout<<"N = ";
//                rep(i,0,N+1) disP(i);
//                dout<<endl;
//                dispAll(S, N+1);
//                dout<<"----------S\n";
            }
        }
        
        
        cout << T[N] << " " << S[N] << endl;
    
    }
    
    
    
#ifdef OUTPUT2TEXTFILE
    outputfile.close();
    cout << "\"" << OutputFilePath << "\"" << endl;
#endif
    
    return 0;
}

Measured memory_bytes: 14500