#include <stdio.h>
#include <stdlib.h>
#define tetra(N) N*(N+1)*(N+2)/6
#define N_MAX 1000000

int main(int argc, char* argv[]){
	int *a=malloc((N_MAX+1)*sizeof(int)), *b=malloc((N_MAX+1)*sizeof(int)), i, j;
	
	/* initialize */
	for(i=1; i<=N_MAX; i++) a[i]=N_MAX, b[i]=N_MAX;
	
	/* solve */
	for(i=1; tetra(i)<=N_MAX; i++){
		a[tetra(i)]=1;
		if(i%4==1) b[tetra(i)]=1;
	}
	for(i=1; i<=N_MAX; i++)
		for(j=1; i+tetra(j)<=N_MAX; j++){
			if(a[i+tetra(j)]>a[i]+1) a[i+tetra(j)]=a[i]+1;
			if(j%4==1 && b[i+tetra(j)]>b[i]+1) b[i+tetra(j)]=b[i]+1;
		}
	
	/* show */
	while(scanf("%d",&i), i!=0) printf("%d %d\n",a[i],b[i]);
	
	free(a), free(b);
	
	return 0;
}