#include <stdio.h>
#include <stdlib.h>
#define MAX 1000000 - 1
int main(){
	int n,i,input;
	int tn, tmp;
	int tetra_n[181];
	int *tetra_sum, *tetra_sum_odd;
	char a[10];
	for (n = 0; n <= 180; n++) tetra_n[n] = n*(n+1)*(n+2) / 6;
	tetra_sum = (int *) malloc(sizeof(int) * (MAX+1));
	tetra_sum_odd = (int *) malloc(sizeof(int) * (MAX+1));
	tetra_sum[0] = 0;
	tetra_sum_odd[0] = 0;
	for (i = 1; i <= MAX; i++){ 
		tetra_sum[i] = MAX; 
		tetra_sum_odd[i] = MAX;
	}
	for (n = 1; n <= 180; n++){
		tn = tetra_n[n];
		if (tn % 2 == 0) {
			for (i = tn; i <= MAX; i++){
				tmp = tetra_sum[i-tn] + 1;
				if (tmp < tetra_sum[i]) tetra_sum[i] = tmp;
			}
		} else {
			for (i = tn; i <= MAX; i++){
				tmp = tetra_sum[i-tn] + 1;
				if (tmp < tetra_sum[i]) tetra_sum[i] = tmp;
				tmp = tetra_sum_odd[i-tn] + 1;
				if (tmp < tetra_sum_odd[i]) tetra_sum_odd[i] = tmp;
			}
		}
	}
	while (1){
		input = atof(fgets(a, sizeof(a) / sizeof(a[0]), stdin));
		if (input == 0) break;
		printf("%d %d\n", tetra_sum[input], tetra_sum_odd[input]);
	}
	free(tetra_sum);
	free(tetra_sum_odd);
 	return 0;
}