program	main
  implicit none
  integer k,s,i,j
  integer,allocatable::a(:,:)
  read*,k,s
  allocate(a(k+1,k+1))
  forall(i=0:k,j=0:k)a(i+1,j+1)=s-i-j


  print*,count(a.ge.0.and.a.le.k)
!  print*,a.ge.0                                                                

     !forall(j=0:k)a(i+1,j+1)=i+j                                               
end program main
