program sum_of_three_integers
  implicit none
  integer :: k, s, i, m
  read(*,*) k, s
  m = 0
  do i = 0, min(k,s)
    m = m+max(0,min(k,s-i)-max(0,s-i-k)+1)
  end do
  write(*,'(i0)') m
  stop
end program sum_of_three_integers