while line = gets
	n, x = line.split( " " ).map { | val | val.to_i }
	break if 0 == n && 0 == x

    cnt = 0
    ave = x / 3
    for i in ( 1 .. ave-1 )
    	ave2 = (x-i) / 2
        for j in ( i+1 .. ave2 )
        	k = x-i-j
        	if j < k && k <= n
                cnt += 1
            end
        end
    end
 
    puts( cnt )
end