module Main where

import Control.Applicative
import Control.Monad
import Data.List

ds :: [Int]
ds = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine
    let cs = do
        s <- [1 .. a]
        t <- if s == a then [1 .. b] else [1 .. ds !! (s - 1)]
        guard (s == t)
        return (s, t)
    print $ length cs