#include<stdio.h>
#define S(type,x) fscanf(stdin,"%"#type,&x)
#define N (int)1e6
#define MIN(a,b) a<b?a:b
int dp[N + 1],
	odd[N + 1];
int main() {
	int i;
	for (i = 0; i <= N; i++) dp[i] = odd[i] = i;
	int p = 4, n = 3;
	for (; p <= N; n++) {
		for (i = 0; i+p <= N; i++) {
			dp[i + p] = MIN(dp[i + p], dp[i] + 1);
			if (p & 1) odd[i + p] = MIN(odd[i + p], odd[i] + 1);
		}
		p = n*(n + 1)*(n + 2) / 6;
	}
	while (S(d, n), n)fprintf(stdout, "%d %d\n", dp[n], odd[n]);
	return 0;
}