#include <iostream>
#include <vector>
using namespace std;
int getMinBlocks(vector<int> blockList, int targetSum, int currentSum)
{
static vector<int> MinBlocksNeeded(targetSum+1);
//Initilize the ways to make stack to a large number
if (!currentSum)
{
for (int i(0); i <= targetSum; i++)
{
MinBlocksNeeded[i] = 1000;
}
MinBlocksNeeded[0] = 0;
}
for (int i(0); i < blockList.size(); i++)
{
if (blockList[i] <= currentSum)
{
if ( MinBlocksNeeded[ currentSum - blockList[i] ] < MinBlocksNeeded[currentSum] )
{
MinBlocksNeeded[currentSum] = MinBlocksNeeded[ currentSum - blockList[i] ] + 1;
}
}
else
{
break;
}
}
if (targetSum == currentSum)
{
return MinBlocksNeeded[targetSum];
}
else
{
return getMinBlocks(blockList, targetSum, currentSum + 1);
}
}
int main()
{
int targetH(0);
int nBlocks(0);
cin>>targetH;
cin>>nBlocks;
vector<int> blockList(nBlocks);
for (int i(0); i < nBlocks; i++)
{
cin>>blockList[i];
}
//Assume the blocks are ordered from smallest to largest.
cout<< getMinBlocks(blockList, targetH, 0) <<endl;
cin.get();
return 0;
}