/*
 * 1167.c: Pollock's conjecture
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* constant */

#define MAX_N	(1000000)
#define MAX_THN	(200)

/* global variables */

static int sums[MAX_N + 1], osums[MAX_N + 1];
static int thns[MAX_THN], othns[MAX_THN];

/* subroutines */

void min_sums(int *sums, int n_thn, int *thns) {
  int i, j, k, s1, thn;

  for (i = 0; i <= MAX_N; i++) sums[i] = i;

  for (k = 0; k < n_thn; k++) {
    thn = thns[k];
    for (i = thn; i <= MAX_N; i++) {
      j = i - thn;
      s1 = sums[j] + 1;
      if (sums[i] > s1) sums[i] = s1;
    }
  }
}

/* main */

int main(int argc, char **argv) {
  int k, n, n_thn, n_othn, thn;

  n_thn = n_othn = 0;
  for (k = 0;; k++) {
    thn = k * (k + 1) * (k + 2) / 6;
    if (thn >= MAX_N) break;
    thns[n_thn++] = thn;
    if (thn & 1) othns[n_othn++] = thn;
  }

  min_sums(sums, n_thn, thns);
  min_sums(osums, n_othn, othns);

  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;

    printf("%d %d\n", sums[n], osums[n]);
  }

  return 0;
}