// Arup Guha
// 3/30/2014
// Solution to 2014 Chicago Invitational (NAIPC) Problem G: Integer Estate Agent.

import java.util.*;

public class g {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		// Process all cases.
		while (n != 0) {

			// i = # terms in sum
			int cnt = 0;
			for (int i=1; i<2000; i++) {

				// Subtract this out.
				int sum = (i-1)*i/2;
				if (sum > n) break;

				// Leftover must be divisible by i and greater than it.
				int t = n - sum;
				if (t%i == 0 && t>i)
					cnt++;
			}

			// Solve and move on.
			System.out.println(cnt);
			n = stdin.nextInt();
		}
	}
}