{-# LANGUAGE ScopedTypeVariables #-}

module Main where

import Data.Array
import Data.Array.IO

import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as BS
bytestr2Int = fst . fromJust . BS.readInt
getInt = bytestr2Int <$> BS.getLine
getIntL_H = map bytestr2Int. BS.words <$> BS.getLine
getIntL_V n = replicate n $ getInt
getInt2D n = replicate n $ getIntL_H


data Curr = Zero
          | One Int
          | Two Int Int
          | Filled Int Int Int
          deriving (Show)

main :: IO ()
main = do
    [k,s] <- getIntL_H
    (m::IOUArray (Int,Int,Int) Int) <- getMmemo k s (repeat (-1))
    putStrLn . show =<< check k s 0 Zero m

getMmemo r c ls = thaw $ listArray ((0, 0, 0), (r, c, 2)) ls

check k s a c m =
    if s<0 then
        pure 0
    else if k<a then do
        pure 0
    else case c of
        Zero -> do
            mv <- readArray m (a,s,0)
            if mv<0 then do
                v <- next c (One a)
                writeArray m (a,s,0) v
                pure v
            else
                pure mv
        (One x) -> do
            mv <- readArray m (a,s,1)
            if mv<0 then do
                v <- next c (Two x a)
                writeArray m (a,s,1) v
                pure v
            else
                pure mv
        (Two x y) -> do
            mv <- readArray m (a,s,2)
            if mv<0 then
                if a==s then do
                    v <- next c (Filled x y a)
                    writeArray m (a,s,2) v
                    pure v
                else do
                    v <- check k s (a+1) c m
                    writeArray m (a,s,2) v
                    pure v
            else
                pure mv
        _ -> do
            pure 1
    where
        next rm ad = (+) <$> check k s (a+1) rm m <*> check k (s-a) 0 ad m