import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int INF = 1<<30;
    while(true) {
        int N = readln.chomp.to!int;
        if (N==0) break;
        int[] ary = new int[N+1];
        ary[] = INF;
        ary[0] = 0;
        while(true) {
            foreach(int i; 0..N) {
                if (ary[i]<INF) {
                    for(int n=1; ; n++) {
                        if (i+func(n)<=N) {
                            ary[i+func(n)] = min(ary[i+func(n)], ary[i]+1);
                        } else {
                            break;
                        }
                    }
                }
            }
            if (ary[N] < INF) break;
        }
        ary[N].write;
        " ".write;
        ary[] = INF;
        ary[0] = 0;
        while(true) {
            foreach(int i; 0..N) {
                if (ary[i]<INF) {
                    for(int n=1; ; n++) {
                        if (func(n)%2==0) continue;
                        if (i+func(n)<=N) {
                            ary[i+func(n)] = min(ary[i+func(n)], ary[i]+1);
                        } else {
                            break;
                        }
                    }
                }
            }
            if (ary[N] < INF) break;
        }
        ary[N].writeln;
    }
}
int func(int n) {
    return n*(n+1)*(n+2)/6;
}