#include <stdio.h>

#define min(a, b)   (((a) < (b))?(a):(b))

int n1[1000000];
int n2[1000000];

int main(void)
{
    int a;
    int i, j, k;
    int n;
    
    for (i = 0; i < 1000000; i++){
        j = 1;
        while (1){
            n = j * (j + 1) * (j + 2) / 6;
            if ((i + n) >= 1000000){
                break;
            }
            if (n1[i + n] == 0){
                n1[i + n] =  n1[i] + 1;
            }
            else {
                n1[i + n] = min(n1[i + n], n1[i] + 1);
            }
            if (n % 2 == 1){
                if (n2[i + n] == 0){
                    n2[i + n] =  n2[i] + 1;
                }
                else {
                    n2[i + n] = min(n2[i + n], n2[i] + 1);
                }
            }
            j++;
        }
    }

    
    while (1){
        scanf("%d", &a);
        if (a == 0){
            break;
        }
        printf("%d %d\n", n1[a], n2[a]);
    }
    
    return (0);
}

