#include <iostream>
using namespace std;
const int MAX_N = 10;
const int MAX_S = 1001;

int n,m;
int dp[MAX_S][MAX_N];

void solve(){
    for(int i = 1 ; i < MAX_S ; i++){
        dp[i][1] = 1;
    }
    for(int i = 2 ; i < MAX_S ; i++){
        for(int j = 2 ; j < MAX_N ; j++){
            if(j-i >= 0){
                dp[i][j] = dp[i][j-1];
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
            if(i >= 4){
                dp[i][j] += dp[i-3][j];
            }
        }
    }
}

int main(){
    solve();
    while(cin >> n >> m, n + m){
        cout << dp[m][n] << endl;
    }
    
    return 0;
}