type ABC(stream:System.IO.TextReader) =
  member this.Scan4 f1 f2 f3 f4 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2], f4 a.[3]))

let util = ABC(stdin)

let rec gcd64 (a:int64) (b:int64) =
  match a % b with
  | 0L -> b
  | c -> gcd64 b c

let A,B,C,D = util.Scan4 int64 int64 int64 int64
let E = C * D / (if C > D then gcd64 C D else gcd64 D C) // gcm

[C;D;E]
|> List.map (fun a -> B/a - (A-1L)/a)
|> fun xs -> B - A + 1L - (xs.[0] + xs.[1] - xs.[2])
|> printfn "%d"
