import qualified Data.ByteString.Char8 as B import Data.Maybe import Data.Functor readInts :: B.ByteString -> [Int] readInts x = fst <$> mapMaybe B.readInt (B.words x) getParams :: B.ByteString -> (Int, Int) getParams x = (x' !! 0, x' !! 1) where x' = readInts x primes :: Int -> Double -> [(Double, Int)] primes n p = sieve (zip (replicate n 1.0) [2..n]) where sieve ((l, x):xs) = (l, x) : sieve ([((erase y x) * k, y) | (k, y) <- xs]) sieve [] = [] erase x y = if x `mod` y == 0 then 1 - p else 1 main = do l <- words <$> getLine let n = read (l !! 0) :: Int p = read (l !! 1) :: Double k = primes n p (putStrLn . show) (foldr (\ (v, _) r -> v + r) 0.0 k)