#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 2000;
const int MAX_S = 20000;
int arr[MAX_N];
int n, s, minCards = MAX_S + 1;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    for(int i = n - 1; i >= 0; i--)
    {
        int currSum = 0, cards = 0;
        for(int j = i; j >= 0; j--)
        {
            cards += (s - currSum) / arr[j];
            currSum += ((s - currSum) / arr[j]) * arr[j];
            if(currSum == s)
            {
                break;
            }
        }
        if(cards < minCards)
        {
            minCards = cards;
        }
    }
    cout << minCards;
    return 0;
}
