#include <stdio.h>
#include <math.h>
#include <vector>
using namespace std;

int n;
vector<int> tetora;
vector<int> dp(1000001, 10000);
vector<int> dp2(1000001, 100000);

void msk()
{
    dp[0] = dp2[0] = 0;

    for (int i = 1;; i++)
    {
        int tmp = i * (i + 1) * (i + 2) / 6;
        if (tmp > 1000000)
            break;

        for (int j = tmp; j < 1000001; j++)
        {
            dp[j] = min(dp[j], dp[j - tmp] + 1);
            if (tmp % 2 != 0)
            {
                dp2[j] = min(dp2[j], dp2[j - tmp] + 1);
            }
        }
    }
}

int main()
{
    msk();
    while (1)
    {
        scanf("%d", &n);
        if (n == 0)
            return 0;
        printf("%d %d\n", dp[n], dp2[n]);
    }
}
