#include <stdio.h>

#define min(x, y) ((x)<(y)?(x):(y))

int s[200], dp0[1000010], dp1[1000010];

int main(void)
{
    int i, j, k, n;
    for(k=1;k*(k+1)*(k+2)<6000000;++k) {
        int t=k*(k+1)*(k+2)/6;
        dp0[t]=1;
        if (t%2) dp1[t]=1;
        s[k]=t;
    }
    for(i=1;i<1000010;++i) {
        if (!dp0[i]) {
            dp0[i]=i;
            for(j=1;j<k&&s[j]<i;++j)
                dp0[i]=min(dp0[i], dp0[i-s[j]]+dp0[s[j]]);
        }
        if (!dp1[i]) {
            dp1[i]=i;
            for(j=1;j<k&&s[j]<i;j+=2)
                dp1[i]=min(dp1[i], dp1[i-s[j]]+dp1[s[j]]);
        }
    }

    while (scanf("%d", &n), n) {
        printf("%d %d\n", dp0[n], dp1[n]);
    }
    return 0;
}