import scala.io.StdIn._

object Main extends App {
  val n: Long = readLine.toInt
  val a: Array[Long] = (1 to 5).map(_ => readLine.toLong).toArray
  var cnt = 0
  var city: Array[Long] = new Array[Long](6)
  city(0) = n
  while (city(5) < n) {
    city = move(city, a)
    cnt += 1
  }
  def move(c: Array[Long], arr: Array[Long]): Array[Long] = {
    for (i <- (4 to 0 by -1)) {
      c(i) match {
        case x if (x >= arr(i)) => {
          c(i + 1) += arr(i)
          c(i) -= arr(i)
        }
        case x if (x < arr(i)) => {
          c(i + 1) += c(i)
          c(i) = 0
        }
      }      
    }
    c
  }
  println(cnt)
}