comb :: Int -> [Int] -> [[Int]]
comb 0 [] = [[]]
comb _ [] = []
comb n (x:xs) = map (x:) (comb (n-1) xs) ++ (comb n xs)

solv' :: [Int] -> [[Int]]
solv' (n:l:_) = filter (\y -> (sum y) == l) $ comb 3 [1..n]

main = getContents >>= mapM_ (print . length . solv') . takeWhile (/= [0,0]) . map (map read . words) . lines