module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
solve :: [Int] -> [Int]
solve as = 
    fst <$> (sortOn snd $ zip [1..] as)


divMax :: Int -> Int -> (Int, Int)
divMax a b = go a 0 where
    go acc n = let
        (x, y) = acc `divMod` b
        in
            if y == 0 then go x (n + 1) else (acc, n)

primeNums :: Int -> [(Int, Int)]
primeNums a = if last == 1 then reverse primeList else reverse $ (last, 1) : primeList where
    findMax = floor . sqrt . fromIntegral $ a
    go (acc, lst) divisor = 
        let
            (dividedNum, count) = acc `divMax` divisor
        in
            if count == 0 then (acc, lst) else (dividedNum, (divisor, count) : lst)
    (last, primeList)  = foldl' go (a, []) [2..findMax]
    
main = do
    (a, b) <- readTuple2
    print $ (+1) . length $ intersect (fst <$> primeNums a) (fst <$> primeNums b)