#include<bits/stdc++.h>
using namespace std;
int dp(int s, int arr[], int n) {
    if(s == 0) return 0;
    int minimum = -1;
    for(int i = n - 1; i >= 0; i--) {
        if(s == arr[i]) return 1;
        if(arr[i] > s) continue;
        int curr = s % arr[i];
        int a;
        if((a = dp(curr, arr, n) + s / arr[i]) < minimum || minimum == -1) {
            minimum = a;
        }
    }
    return minimum;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int s, n;
    cin >> s >> n;
    int arr[n];
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    cout << dp(s, arr, n);


    return 0;
}
