import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl (map read . words) >>= print

solve :: [Int] -> Int
solve [n, k] = length . concatMap (filter (==k)) $ take (n-2) (f lst)
  where
    lst = cycle [4,2,0,9,7,5,3,1,10,8,6]
    f xs = take 5 xs : f (drop 7 xs)

getl :: (String -> a) -> IO a
getl f = f <$> getLine
