import java.lang.Math.min

fun main(args: Array<String>) = p37()

fun p37() {
    val (need) = readLine()!!.split(' ').map { it.toInt() }
    val coins = readLine()!!.split(' ').map { it.toInt() }

    // [value] = minimum number of coins
    val dp = IntArray(need + 1) { Int.MAX_VALUE / 10 }
    dp[0] = 0

    for (coin in coins) {
        for (ni in 0..need - coin) {
            val pay = ni + coin
            dp[pay] = min(dp[pay], dp[ni] + 1)
        }
    }

    val answer = dp.last()

    println(answer)
}

