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