let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let () = Scanf.scanf "%d %d" @@ fun n k ->
  let fact = Array.make (min n k + 2) 1 in
  let perm_n = Array.make (min n k + 2) 1 in
  for i = 0 to min n k do
    fact.(i + 1) <- (i + 1) *^ fact.(i);
    perm_n.(i + 1) <- (n - i) mod m *^ perm_n.(i)
  done;
  let inv_n = power ( *^ ) 1 n (m - 2) in
  Printf.printf "%d\n" @@
  Array.fold_left ( +^ ) 0 @@
  Array.init (min n k + 1) @@ fun i ->
    let inv_fact = power ( *^ ) 1 fact.(i) (m - 2) in
    let comb_n_i = perm_n.(i) *^ inv_fact in
    let comn_n1_i = perm_n.(i + 1) *^ inv_n *^ inv_fact in
    comb_n_i *^ comn_n1_i