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

const int PMAX = 180;
const int OMAX = 45;

#define MAX 1000000
int tp[MAX];
int to[MAX];

int main(void)
{
    int i, j, n;
    int p[PMAX], o[OMAX];

    for (i = j = 1; (n = i * (i + 1) * (i + 2) / 6) < MAX; ++i) {
        p[i] = n;
        if (n % 2 == 1)
            o[j++] = n;
    }

    memset(tp, MAX, sizeof(tp));
    memset(to, MAX, sizeof(to));
    tp[0] = to[0] = 0;
    for (i = 0; i < MAX; ++i)
        for (j = 1; j < PMAX; ++j)
            if (i + p[j] < MAX && tp[i + p[j]] > tp[i] + 1)
                tp[i + p[j]] = tp[i] + 1;
    for (i = 0; i < MAX; ++i)
        for (j = 1; j < OMAX; ++j)
            if (i + o[j] < MAX && to[i + o[j]] > to[i] + 1)
                to[i + o[j]] = to[i] + 1;

    for (;;) {
        int n;

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

        printf("%d %d\n", tp[n], to[n]);
    }

    return 0;
}