program sum_of_three_integers
  implicit none
  integer :: k, s, i, m = 0
  read(*,*) k, s
  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
end program sum_of_three_integers