main = do
       x<-getLine
       let (a:b:c:d:[])=map read (words x)::[Integer]
           e=c * d `div` (gcd c d)
       print $ (f b c d e)-(f (a-1) c d e)
       where f s c d e=s-(s `div` c) -(s `div` d) + (s `div` e)