import qualified Data.Vector.Unboxed as V

main = getLine >>= print.solve.map read.words
solve [n, k]
  | k >= n - 1 = part n n
  | otherwise = foldl1 (+%) [ comb n k *% part k (n-k) | k <- [0..k] ]

mo = 10^9 + 7 :: Int
a ^% b
  | b < 0 = 0
  | b == 0 = 1
  | otherwise = f a b
  where
    f a b
      | even b = f (a *% a) (quot b 2)
      | b == 1 = a
      | otherwise = g (a *% a) (quot b 2) a
    g a b c
      | even b = g (a *% a) (quot b 2) c
      | b == 1 = a *% c
      | otherwise = g (a *% a) (quot b 2) (a *% c)
a *% b = rem (a * b) mo
a /% b = a *% (b ^% (mo - 2))
factt = V.fromList $ scanl (*%) 1 [1..400000]
fact = (factt V.!)
comb a b = fact a /% fact b /% fact (a-b)
a -% b = rem (mo + a - b) mo
a +% b = rem (a + b) mo
part a b = fact (a+b-1) /% fact a /% fact (b-1)