# class Array
#   def get(idx)
#     if 0 <= idx && idx < self.size
#       self.at(idx)
#     else
#       raise IndexError.new("index #{idx} outside of array bounds: 0...#{self.size}")
#     end
#   end
#
#   # NOTE: Overwrite
#   def [](idx)
#     get(idx)
#   end
# end


def make_2d_array(n, m, init)
  n.times.map{[init] * m}
end

def show_table(table)
  table.each{|row|
    puts(row.map(&:inspect).join(' '))
  }
end

def min(a, b)
  a < b ? a : b
end

n, _   = gets.split(' ').map(&:to_i)
# Available coins
coins = gets.split(' ').map(&:to_i)

# Initialize DP table
dp_table = make_2d_array(coins.size+1, n+1, 0) # (coins.size + 1).times{[nil] * (coins.size + 1)}
(1..n).each{|j|
  dp_table[0][j] = Float::INFINITY
}
dp_table[0][0] = 0


(1..coins.size).each{|i|
  (0..n).each{|j|
    coin = coins[i-1]
    if 0 <= j - coin
      dp_table[i][j] = min(dp_table[i-1][j], dp_table[i][j - coin] + 1)
    else
      dp_table[i][j] = dp_table[i-1][j]
    end
  }
}



puts(dp_table[-1][-1])
