n = gets.to_i a = gets.chomp.split.map(&:to_i) c = 0 n.times do |i| c += 1 if (i+1) % a[0] == 0 || (i+1) % a[1] == 0 || (i+1) % a[2] == 0 end p c