n = gets.to_i

carries = []
5.times {
  carries.push(gets.to_i)
}

cities = [n, 0, 0, 0, 0, 0]
p cities

time = 0
while cities[5] < n
  time += 1
  4.downto(0) {|i|
    tmp = cities[i] > carries[i] ? carries[i] : cities[i]
    cities[i] -= tmp
    cities[i+1] += tmp
  }
  
  p cities
end

puts time