import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]) = {
    val n = readLine.split(" ")(0).toInt
    val c = readLine.split(" ").map(_.toInt)
    val minVal = (0 to n+1).toArray

    for( i <- 2 to n+1 ) {
      for( j <- c ) {
        if(j<=i && minVal(i-j) + 1 < minVal(i)) {
          minVal(i) = minVal(i-j)+1
        }
      }
    }
    println(minVal(n))
  }
}