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

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

        if (n == 0) return;

        solve(n);
    }
}

void solve(int n) {
    int l=1, r=1;
    int v;
    int cnt;

    while (r <= n) {
        if (v < n) {
            v += r++;
        }
        else {
            if (v == n) cnt++;
            v -= l++;
        }
    }

    writeln(cnt);
}


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);
        }
    }
}