#include<stdio.h>
int compare_ints(const void* a, const void* b)
{

    int arg1 = *(const int*)a;
    int arg2 = *(const int*)b;
    return arg2 - arg1;
}

int main()
{
    int S, N, sum=0;
    scanf("%d %d",&S,&N);
    int numbers[N], i,counter=0;
    for(i = 0; i<N; i++)
    {
        scanf("%d",&numbers[i]);
    }
    qsort(numbers, N, sizeof(int), compare_ints);
    while(sum+numbers[0]<S)
    {
        sum = sum + numbers[0];
        counter++;
    }
    while(sum<S)
    {
        for(i = 0; i<N; i++)
        {
            if(sum + numbers[i] <= S)
            {
                sum = sum + numbers[i];
                counter++;
            }
        }
    }
    printf("%d",counter);
    return 0;
}
