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|
        (x / coin).downto(0){|i|
            rest = x - coin * i
            next if i >= arr[x]
            arr[x] = i + arr[rest] if arr[x] > i + arr[rest]
        }
    }
}
puts arr[n]
