#include <stdio.h>

#define MAX_X     1000000
#define INFINITY  MAX_X
#define tetra(n)  ((n) * ((n)+1) * ((n)+2) / 6)

/* compute all solutions for x = 1 to (MAX_X-1) */
void polloc(int solution[], int oddOnly)
{
  int i, j, t;

  /* initialize */
  for (i = 1; i < MAX_X; i++) {
    solution[i] = INFINITY;
  }
  for (i = 1; (t = tetra(i)) < MAX_X; i++) {
    if (! oddOnly || t % 2 == 1) {
      solution[t] = 1;
    }
  }

  /* dynamic programming */
  for (i = 1; i < MAX_X; i++) {
    for (j = 1; (t = tetra(j)) < i; j++) {
      if (solution[i] > solution[t] + solution[i - t]) {
          solution[i] = solution[t] + solution[i - t];
      }
    }
  }
}

int main()
{
  static int solution[2][MAX_X];
  int x;

  polloc(solution[0], 0);
  polloc(solution[1], 1); /* odd only */

  for (;;) {
    scanf("%d", &x);
    if (x == 0) break;
    printf("%d %d\n", solution[0][x], solution[1][x]);
  }
  return 0;
}