let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
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 perm n k =
  Array.fold_left ( *^ ) 1 @@
  Array.init k @@ fun i -> (i + n - k + 1) mod m
let comb n k = power ( *^ ) (perm n k) (perm k k) (m - 2)

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