#include <iostream>
//#include <algorithm>
// #include <bits/stdc++.h>

using namespace std;

int max_(int arr[], int l) {
    //returns the index of the largest value
    int max_n = 0, max_i = 0;
    for ( int i = 0; i < l; i ++ ) {
        if ( max_n < arr[i] ) {
            max_i = i;
            max_n = arr[i];
        }
    }
    return max_i;
}

void sort_(int *arr, int l) {
    // sorts the array from greather to smaller
    for ( int i = l - 1; i > 0; i -- ) {
        int index = max_(arr, i + 1);
        if ( i == index ) continue;
        arr[i] += arr[index]; // a + b
        arr[index] = arr[i] - arr[index]; // b = a + b - b;
        arr[i] -= arr[index]; // a = a + b - a
    }
}

int getSum(int arr[], int e, int n, bool dev) {
    // the actual part of the code
    int count = 0;
    while(n > 0 ) {
        bool pass = false;
        for ( int i = e - 1; i >= 0; i -- ) {
            //cout << i << endl;
            if ( n - arr[i] >= 0  ) {
                /*if ( n / arr[i] > 1&& dev ) {
                    int del = n / arr[i], ends[del];
                    return del;
                } else {*/
                n -= arr[i];
                count ++;
                //}
                pass = true;
            };
        }
        if ( !pass ) {
            return -1;
        }
    }
    return count;
}

int code(int arr[], int n, int s) {
    //sorts
    sort_(arr, s);
    int e = s, o[2*s];
    while (e > 0 ) {
        // going through every numbers possibilities by sipping most of the unlikely once to save time
        // it only goes through every element and if its less than the number, substracts
        o[s - e] = getSum(arr, e-1, n, false);
        o[2*s - e] = getSum(arr, e--, n, true);
    }
    //now the output will be on index 0 if there wasn't any fail cases. Otherwise it will go to the next until it finds the answer which must be > 0.
    sort_(o, 2*s);
    for ( int i = 0; i < 2*s; i ++ ) {
        if ( o[i] > 0 ) {
            return o[i];
        }
    }
}

int main () {
    int n, s;
    cin >> n >> s;
    int arr[s];
    for ( int i = 0; i < s; i ++ ) {
        cin >> arr[i];
    }
    cout << code(arr, n, s);
    return 0;
}
