// Aizu 1167: Pollock's conjecture
// 2017.9.14 bal4u@uu

#include <stdio.h>

#define min(a,b) ((a)<=(b)?(a):(b))
#define MAX 1000000
#define N 181
int tbl[N+3], a[MAX+3], b[MAX+3];

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

	for (n = 1; n <= N; n++) tbl[n] = tbl[n-1] + (n*(n+1) >> 1);
	for (i = 1; i <= MAX; i++) {
		a[i] = b[i] = i;
		for (j = 0; tbl[j] <= i; j++) {
			a[i] = min(a[i], a[i-tbl[j]]+1);
			if (tbl[j] & 1) b[i] = min(b[i], b[i-tbl[j]]+1);
		}
	}
	while(scanf("%d", &n) && n)	printf("%d %d\n", a[n], b[n]);
	return 0;
}