import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

enum lim = 10^^6;

void main() {
    auto f = new int[](2000);
    foreach (i ; 1 .. 2000) {
        f[i] = f[i - 1] + i;
    }
    foreach (i ; 1 .. 2000) {
        f[i] += f[i - 1];
    }
    f = f.filter!(x => x < lim).array;
    debug {
        writeln(f);
        writeln(f.length);
    }
    auto n = f.length.to!int;
    auto dp = new int[](lim);
    auto dp2 = new int[](lim);
    dp[] = inf;
    dp2[] = inf;
    dp[0] = dp2[0] = 0;

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. lim) {
            if (j + f[i] < lim) {
                chmin(dp[j + f[i]], dp[j] + 1);
                if (f[i] % 2) chmin(dp2[j + f[i]], dp2[j] + 1);
            }
        }
    }

    while (true) {
        int x;
        scan(x);
        if (x == 0) return;
        writefln("%s %s", dp[x], dp2[x]);
    }
}














void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

