#include <stdio.h>
 
int main() {
    int sep, n, i, j, count;
     
    while(1) {
        scanf("%d", &n);
        if(n == 0) {
            break;
        }
         
        count = 0;
        for(i = 2;; i ++) {
            sep = n/i;
            if(i%2 == 0 && sep - i/2 - 1 <= 0 || i%2 != 0 && sep - i/2 <= 0) { break; }
             
            if(i%2 == 0) {
                if((sep + (sep + 1))*(i/2) == n) {
                    count ++;
                }
            }
            else {
                if(sep + sep*2*(i/2) == n) {
                    count ++;
                }
            }
        }
         
        printf("%d\n", count);
    }
     
    return 0;
}