program sum_of_three_integers
  implicit none
  integer :: k, s, x, y, m
  read(*,*) k, s
  m = 0
  do x = 0, min(k,s)
    do y = 0, min(k,s-x)
      if (s-x-y.le.k) m = m+1
    end do
  end do
  write(*,'(i0)') m
  stop
end program sum_of_three_integers