#include <stdio.h>

int N(int n){
  return n*(n+1)*(n+2)/6;
}

main(){
  int i,j,n,fx[1000000],d=1,min,fy[1000000];

  fx[0] = 0;
  fy[0] = 0;
  for(i=1;i<1000000;i++){
    if(i == N(d+1)) d++;

    min = -1;
    for(j=1;j<=d;j++){
      if(min == -1 || fx[i-N(j)]+1 < min) min = fx[i-N(j)]+1;
    }
    fx[i] = min;

    min = -1;
    for(j=1;j<=d;j++){
      if(N(j)%2 == 0) continue;
      else if(min == -1 || fy[i-N(j)]+1 < min) min = fy[i-N(j)]+1;
    }
    fy[i] = min;
  }


  while(1){
    scanf("%d",&n);
    if(n==0) break;
    printf("%d %d\n",fx[n],fy[n]);

  }
  return 0;
}