#include<stdio.h>

int min(int a, int b){
  if(a<b)return a;
  else return b;
}

int dp[2000000];
int DP[2000000];

int main(){
  int i,j,x;

  for(i=1;i<=1000000;i++){
   
    dp[i]=i;
    DP[i]=i;
    for(j=1;;j++){
      x=j*(j+1)*(j+2)/6;
      if(i-x<0)break;
      dp[i]=min(dp[i],dp[i-x]+1);
      if(x%2==1){
	DP[i]=min(DP[i],DP[i-x]+1);
      }
    }
  }


  while(1){
    scanf("%d",&x);
    if(x==0)break;
    printf("%d %d\n",dp[x],DP[x]);
  }
  return 0;
}