  !https://atcoder.jp/contests/abc051/tasks/abc051_b
program main
  implicit none
  integer :: K,S
  integer :: out
  integer :: i,j,l
  read(*,*) K,S
  out = 0
  do l = 0,K
  do j = 0,K
  do i = 0,K
     if (i+j+l == S ) out=out+1
  end do
  end do
  end do
  write(*,'(i0)') out
  stop
end program main
