// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n;

void main() {
    while (true) {
        scan(n);

        if (n == 0) break;

        writeln(solve(n));
    }
}

int solve(int n) {
    int res;

    foreach (l ; 0 .. n) {
        foreach (r ; l + 2 .. n) {
            int x = r * (r + 1) / 2 - l * (l + 1) / 2;

            if (x == n) {
                debug {
                    writeln('[', l, ", ", r, ']');
                }
                res++;
            }
        }
    }
    return res;
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    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);
        }
    }
}