#include <cstdio>
#include <algorithm>
using namespace std;
char dp1[1000001],dp2[1000001];
int main(){
int t[181];
for(int i = 1;i <= 180;++i)
t[i] = i * (i + 1) * (i + 2) / 6;
dp1[0] = dp2[0] = 0;
for(int i = 1;i <= 1000000;++i)
dp1[i] = dp2[i] = 40;
for(int i = 1;i <= 180;++i){
int x = t[i];
char *p1 = &dp1[0],*p2 = &dp1[x];
for(int j = x;j <= 1000000;++j,++p1,++p2)
if(1 + *p1 < *p2) *p2 = 1 + *p1;
}
for(int i = 1;i <= 180;++i){
int x = t[i];
if(x & 1){
char *p1 = &dp2[0],*p2 = &dp2[x];
for(int j = x;j <= 1000000;++j,++p1,++p2)
if(1 + *p1 < *p2) *p2 = 1 + *p1;
}
}
int n;
while(true){
scanf("%d",&n);
if(n == 0) break;
printf("%d %d\n",dp1[n],dp2[n]);
}
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpjaGFyIGRwMVsxMDAwMDAxXSxkcDJbMTAwMDAwMV07CgppbnQgbWFpbigpewogICAgaW50IHRbMTgxXTsKICAgIAogICAgZm9yKGludCBpID0gMTtpIDw9IDE4MDsrK2kpCiAgICAgICAgdFtpXSA9IGkgKiAoaSArIDEpICogKGkgKyAyKSAvIDY7CiAgICAKICAgIGRwMVswXSA9IGRwMlswXSA9IDA7CiAgICAKICAgIGZvcihpbnQgaSA9IDE7aSA8PSAxMDAwMDAwOysraSkKICAgICAgICBkcDFbaV0gPSBkcDJbaV0gPSA0MDsKICAgIAogICAgZm9yKGludCBpID0gMTtpIDw9IDE4MDsrK2kpewogICAgICAgIGludCB4ID0gdFtpXTsKICAgICAgICAKICAgICAgICBjaGFyICpwMSA9ICZkcDFbMF0sKnAyID0gJmRwMVt4XTsKICAgICAgICAKICAgICAgICBmb3IoaW50IGogPSB4O2ogPD0gMTAwMDAwMDsrK2osKytwMSwrK3AyKQogICAgICAgICAgICBpZigxICsgKnAxIDwgKnAyKSAqcDIgPSAxICsgKnAxOwogICAgfQogICAgCiAgICBmb3IoaW50IGkgPSAxO2kgPD0gMTgwOysraSl7CiAgICAgICAgaW50IHggPSB0W2ldOwogICAgICAgIAogICAgICAgIGlmKHggJiAxKXsKICAgICAgICAgICAgY2hhciAqcDEgPSAmZHAyWzBdLCpwMiA9ICZkcDJbeF07CiAgICAgICAgICAgIAogICAgICAgICAgICBmb3IoaW50IGogPSB4O2ogPD0gMTAwMDAwMDsrK2osKytwMSwrK3AyKQogICAgICAgICAgICAgICAgaWYoMSArICpwMSA8ICpwMikgKnAyID0gMSArICpwMTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIGludCBuOwogICAgCiAgICB3aGlsZSh0cnVlKXsKICAgICAgICBzY2FuZigiJWQiLCZuKTsKICAgICAgICAKICAgICAgICBpZihuID09IDApIGJyZWFrOwogICAgICAgIAogICAgICAgIHByaW50ZigiJWQgJWRcbiIsZHAxW25dLGRwMltuXSk7CiAgICB9CiAgICAKICAgIHJldHVybiAwOwp9Cg==