program name

    implicit none
    integer K,S,X,Y,Z
    integer counter,i,num
    read*, K,S
    counter = 0
    X = 0
    do Y = 0, K, 1
        do Z = 0, K, 1
            if ( X+Y+Z==S ) then
                counter = counter + 1
            end if
        end do
    end do
    i = 0
    do i = 1, counter, 1
        num = num*i
    end do
    print*, num
print*, counter
end program