n, m = gets.chomp.split.map(&:to_i)
coins = gets.chomp.split.map(&:to_i).sort.reverse
coins.delete(1)
arr = (0..n).to_a
1.upto(n){|x|
    coins.each{|coin|
        q, r = x.divmod(coin)
        arr[x] = q + arr[r] if arr[x] > q + arr[r]
    }
}
puts arr[n]
