#include <stdio.h>

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

int polloc(int x, int oddOnly)
{
  static int solution[MAX_X];
  int i, j;

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

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

int main()
{
  int x;
  for (;;) {
    scanf("%d", &x);
    if (x == 0) break;
    printf("%d %d\n", polloc(x, 0), polloc(x, 1));
  }
  return 0;
}