#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int N, K, ans;

int main(void) {
    while(scanf("%d%d", &N, &K)) {
        if(N == 0 && K == 0) break;
        ans = 0;
        for(int i = 0; i < (1 << K); i++) {
            int tmp = 0, ct = 0;
            for(int j = 0; j <= K; j++) if(i & (1 << j)) {
                tmp += j;
                ct += 1;
            }
            if(tmp == K && ct == N) {
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}