import std.stdio;
import std.conv;
import std.cstream;
import std.string;

void main(string[] args){
int[1000010] dp,dp1;
int [2002] dp4;
for(int i=1;i<=1000000;i++){
/+
dp3[i]=cast(int)(0.5*i*(i+1));/++/
dp4[i]+=dp3[i]+dp4[i-1];/++/
+/
dp1[i]=0;
dp[i]=0;
//dp2[i]=0;
if(i<2000)dp4[i]+=cast(int)(0.5*i*(i+1)) + dp4[i-1];
}
dp1[1]=0;//ord
dp[1]=0;//odd
for(int i=1;i<=1000000;i++){
int minn=2000000,minnn=2000000;
  for(int j=1;dp4[j]<=i;j++){
       if(minn>dp1[i-dp4[j]]+1)minn=dp1[i-dp4[j]]+1;
       if(dp4[j]%2 != 0){
       if(minnn>dp[i-dp4[j]]+1)minnn=dp[i-dp4[j]]+1;
       }
   
  }
dp1[i]=minn;
dp[i]=minnn;

}



int n,index=0;
while(true){
scanf("%d",&n);
if(n == 0)break;

printf("%d %d\n",dp1[n],dp[n]);
/+
index = 0;
for(int i=1;i<=1000000;i++){
if(dp4[index]<=n)index=i;
else break;
}
+/
/+
for(int i;i<20;i++)writeln(dp4[i]);
printf("\n\n %d\n",index);
+/


}



}