let rec seq s t = if s > t then [] else s :: seq (s + 1) t

let comb lst = 
  let rec iter ret = function
    | [] -> ret
    | hd :: tl -> iter (ret @ List.map (fun x -> hd :: x) ret) tl
  in iter [[]] lst

let _ = 
  try
    while true do
      let n, s = Scanf.scanf "%d %d\n" (fun x y -> (x, y)) in
      if n = 0 && s = 0 then
        raise End_of_file
      else
        Printf.printf "%d\n" @@ List.length @@ List.filter (fun x -> x = s) @@ List.map (List.fold_left (+) 0) @@ List.filter (fun x -> List.length x = n) @@ comb @@ seq 0 9
    done
  with
    End_of_file -> ()