M = 100
N = 10
S = 500
None = -1

@memo = Array.new(M+1) {Array.new(N+1) {Array.new(S+1)}}

def rec(i, j, k)
  return @memo[i][j][k]=0 if j==0
  return @memo[i][j][k]=0 if j==1 && k==0
  return @memo[i][j][k] if @memo[i][j][k]
  result = None
  [i,k].min.downto(1) do |ii|
    break if ii-1<0 || j-1<0
    result = [result, rec(ii-1, j-1, k-ii)+1].max
  end
  @memo[i][j][k] = result
end

while (n,s = gets.split.map(&:to_i)).inject(:+) != 0 do
  p rec(M, n, s)
end