main = do [n,l] <- map read . words <$> getLine print (kamo n l) kamo n l = sum $ map (\p -> l - p * (n-1) + 1) (takeWhile (<= (div l (n-1))) primes) primes :: Integral a => [a] primes = 2 : 3 : [x | i <- [1 ..], j <- [-1, 1], let x = 6 * i + j, isPrime x] where isPrime n = null [i | i <- takeWhile (\p -> p * p <= n) primes, mod n i == 0]