A, B, C, D = gets.strip.split.map(&:to_i)

all = B - A + 1

def count(m)
    m_min = (A.to_f / m).ceil.to_i * m
    m_max = (B.to_f / m).floor.to_i * m

    return (m_max - m_min) / m + 1
end

ccnt = count(C)
dcnt = count(D)
cdcnt = count(C.lcm(D))

result = all - ccnt - dcnt + cdcnt

puts result