#include <iostream>
using namespace std;

int n,s;

int dfs(int i, int sum){
  if(i == n){
    if(sum == s) return sum;
  }

  //iを足さない
  if(dfs(i+1,sum) != 0) return sum;

  //iを足す
  if(dfs(i+1,sum+i) != 0) return sum;

  return 0;
}



int main(){
  while(true){
    cin >> n,s;
    if(n == 0 && s == 0) break;
    cout << dfs(0,0) << endl;
  }
  return 0;
}