#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int c = 0, c2 = 0, c3 = 0;
int blocks[10];
int lowest = 11;

void findNext(int max, int pos, int curHeight, int count, int height){
     int fc, fc2;

     for (fc = pos; fc < max; ++fc){
         if (curHeight + blocks[fc] == height && count < lowest){
            lowest = count;
         }
         findNext(max,fc+1,curHeight + blocks[fc], count +1, height);
     }     
}


int main()
{
    ifstream input("DATA4.txt");
    ofstream output("OUT4.txt");
    string line;
    int height, numBlocks;
    
    
    input>>height;
    getline(input,line);
    input>>numBlocks;
    getline(input,line);
    
    for (c = 0; c < numBlocks; ++c){
        input>>blocks[c];
        getline(input,line);
    }
    
    findNext(numBlocks,0,0,0,height);
    if (lowest != 11)
        output<<lowest+1;
    else
        output<<0;



    

}

