
while true
  n,x = gets.split(" ").map(&:to_i)
  if (n==0&&x==0) then
    break
  end   
  count = 0
  for i in 1..n
    
    for j in 1..n
      if i == j then
        break
      end
      
      for k in 1..n
        if k == j then
          break
        end
        if( x == i + j + k ) then
          count+=1
        end
      end
    end
  end
  puts count
end