{-# OPTIONS_GHC -O2 #-}
import Control.Applicative
import Data.List
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BS
import Data.Maybe (fromJust)

strip    xs = foldr (\x ys -> if x `elem` ys then ys else x:ys) [last xs] xs
stripSeq xs = foldr (\x ya@(y:_) -> if x == y then ya else (x:ya)) [last xs] xs

count ns xs = foldr (\n acc -> length (filter (== n) xs) : acc) [] ns

f :: [Int] -> [Int]
f (n:k:_) = count [1..k].map (sum.stripSeq) .strip.permutations $ replicate k 1 ++ replicate (n-k) 0

main :: IO()
main = interact $ unlines.map show.f.map read.words
