import java.lang.IllegalArgumentException
import java.util.*

fun main(args: Array<String>) {


    var sc = Scanner(System.`in`)

    val n = sc.nextInt()
    val m = sc.nextInt()

    var cs = (0 until m).map { sc.nextInt() }

    // dp[i] i番目のコインを使って、n円払う最小の枚数
    var dp = IntArray(n+1)
    dp[0] = 0
    dp[1] = 1
    for(i in 2..n){
        dp[i] = cs.filter { it <= i }.map { dp[i-it] + 1 }.min() ?: throw IllegalArgumentException()
    }

    println(dp[n])



}


