object Main extends App {
  val (us, limits) = {
    val s = new java.util.Scanner(System.in)
    (s.nextLong(), (1 to 5).map(_ => s.nextLong()).toList)
  }

  // ボトルネックで切り上げ + 残りの移動回数
  val ans = ({
    case m if m >= `us` => limits.length
    case d => (us + d - 1l) / 2l + 4l
  }: Long => Long) (limits.min)

  println(ans)
}
