{- A
f :: [Char] -> String
f (x:y:ys)
    | x == y = "Bad"
    | ys == [] ="Good"
    | otherwise = f (y:ys)

main = getLine >>= putStrLn . f
-}


{- B
del :: Int -> Int -> Int -> Int
del d x y
    | d == abs x = y
    | d == abs y = x
    | otherwise = x + y

f :: [Int] -> String
f (n:l:xs) = do
    let x = [l+i-1 | i <- [1..n] ]
    let d = minimum $ map abs x
    show $ foldr1 (del d) x

main = getLine >>= putStrLn . f . map read . words
-}

--{- C
f (a:b:c:d:xs) = length [x | x <- [a..b], x `mod` c /= 0 && x `mod` d /= 0 ]
main = getLine >>= putStrLn . show . f . map read . words