let i=readLine()!.characters.split(" ").map{Int(String($0))!},C=i[2],D=i[3];func f(x:Int)->Int{return i[1]/x-(i[0]-1)/x};func g(x:Int,_ y:Int)->Int{return y>0 ?g(y,x%y):x};print(f(1)-f(C)-f(D)+f(C*D/g(C,D)))