let choose n k =
  let rec iter n a b = function
  | 0 -> a/b
  | k -> iter (n-1) (a*n) (b*k) (k-1)
  in
  iter n 1 1 k

let combination set k x =
  let rec largest a b x =
    if (choose a b) <= x then a else largest (a-1) b x
  in
  let rec combinadic n x = function
    | 0 -> []
    | i ->
      let m = largest n i x in
      m :: combinadic n (x - (choose m i)) (i-1)
  in
  let idxs = combinadic (List.length set) x k in
  List.map (List.nth set) (List.sort (-) idxs)

let range start stop =
  let rec iter l i = match i-start with
    | 0 -> start::l
    | _ -> iter (i::l) (i-1)
  in iter [] stop

let gen_pat set n =
  let rec iter l = function
    | 0 -> combination set n 0 :: l
    | i -> iter (combination set n i :: l) (i-1)
  in
  iter [] ((choose (List.length set) n) - 1)
      
let () =
  let rec loop () =
    let c = 3 in
    match Scanf.sscanf (read_line ()) "%d %d" (fun n x -> n,x) with
    | 0,0 -> ()
    | n,x ->
      let set = range 1 n in
      let pat = gen_pat set c in
      let filltered = List.filter (fun l -> (List.fold_left (+) 0 l) = x) pat in
      print_int (List.length filltered);
      print_newline ();
      loop ()
  in
  loop ()