import Control.Monad
import Text.Printf
import Control.Applicative
import Data.List as L

dateList = [1212, 1111, 1010, 909, 808, 707, 606, 505, 404, 303, 202, 101]

main :: IO()
main = do
  [a, b] <- map read . words <$> getLine
  printf "%d" $ length $ dropWhile (> a * 100 + b) dateList

