#include <stdio.h>

int main() {
  int N;
  int simen[1000];
  int i, j;
  int value, newValue;
  int data[1000000];

  for(i = 0; i < 1000; i++) {
    simen[i] = i*(i+1)*(i+2)/6;
  }

  while(1) {
    scanf("%d", &N);
    if(N == 0) break;
    data[0] = 0;
    for(i = 1; i <= N; i++) {
      data[i] = 999999;
      for(j = 1; j <= i; j++) {
	if(simen[j] > i) break;
	newValue = data[i-simen[j]]+1;
	if(newValue < data[i]) data[i] = newValue;
      }
    }
    printf("%d ", data[N]);
    for(i = 1; i <= N; i++) {
      data[i] = 999999;
      for(j = 1; j <= i; j++) {
	if(simen[j] > i) break;
	if(simen[j] % 2 == 0) continue;
	newValue = data[i-simen[j]]+1;
	if(newValue < data[i]) data[i] = newValue;
      }
    }
    printf("%d\n", data[N]);
  }
  return 0;
}