A, B, C, D, E = gets.split.map(&:to_i) T = (A + B).lcm(C + D) a1 = ([1] * A + [0] * B) * (Rational(T, A + B).ceil + 1) a2 = ([1] * C + [0] * D) * (Rational(T, C + D).ceil + 1) ans = 0 cnt = 0 0.upto(T - 1) do |t| next if a1[t] == 0 next if a2[t] == 0 cnt += 1 end ans += cnt * (E / T) R = E % T 0.upto(R - 1) do |r| next if a1[r] == 0 next if a2[r] == 0 ans += 1 end puts ans