/*
AizuOnline A1167
Title Pollock's conjecture
@kankichi573
*/
#include <stdio.h>
#include <limits.h>
#define UPPER 181
int n;
int tetrah[UPPER+1];
int ans_table[1000000];
int ans_table_odd[1000000];
//
int find_odd(int x)
{
        int ret=find(x);
        if((ret % 4)==1)
                return(ret);
        else if((ret % 4)==0)
                return(ret-3);
        else if((ret % 4)==2) 
                return(ret-1);
        else
                return(ret-2);
}
int find_(int x,int l,int u)
{
        int c;

        if(x>=tetrah[l] && x<tetrah[l+1])
                return(l);
        if(x>=tetrah[u-1] && x<tetrah[u])
                return(u-1);
        c=(l+u)/2;
        if(x>=tetrah[c] && x<tetrah[c+1])
                return(c);
        if(x>=tetrah[c+1])
                return(find_(x,c+1,u));
        if(x<tetrah[c])
                return(find_(x,l,c-1));

}
int find(int x)
{
        return(find_(x,1,UPPER));
}

void init()
{
        int i;
        for(i=1;i<=UPPER;i++)
                tetrah[i]=i*(i+1)*(i+2)/6;

}

int solve_odd(int x)
{
        int i,min_,ret,v;

        if(ret=ans_table_odd[x])
                return(ret);
        if(x<tetrah[5])
                return(x);
        
        min_=INT_MAX;
        for(i=find_odd(x);i>=1;i -= 4)
        {
                v=x - i*(i+1)*(i+2)/6;
                if(v==0)
                        return(1);
                ret=solve_odd(v);
                if(ret < min_)
                        min_ = ret;
        }
        ans_table_odd[x]=min_+1;
        return(min_+1);
}

int solve(int x)
{
        int i,min_,v,f,ret;
        
        //printf("SV=%d\n",x);
        if(ret=ans_table[x])
                return(ret);

        if(x<tetrah[2])
                return(x);

        min_=INT_MAX;

        f=find(x);
        //printf("F=%d %d",f,f*(f+1)*(f+2)/6);
        for(i=f;i>=2;i--)
        {
                v=x - i*(i+1)*(i+2)/6;
                if(v==0)
                        return(1);
                ret=solve(v);
                if(ret < min_)
                        min_ = ret;
        }
        ans_table[x]=min_+1;
        return(min_+1);
}
main()
{
        int i;

        init();

        for(i=0;i<1000000;i++)
        {
                solve(i);
                solve_odd(i);
        }
        while(EOF!=scanf("%d",&n) && n)
        {
                // printf("%d \n",solve(n));
                printf("%d %d\n",solve(n),solve_odd(n));
        }
        return(0);
}