#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int c,n;
cin>>c>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
sort(arr,arr+n);
reverse(arr,arr+n);
int sum=0;
int t=c;
while(c){
for(int i=0;i<n;i++){
if(c>=arr[i]){
c-=arr[i];
sum++;
}
}
}
if(sum==6&&t<25){cout<<"3\n";return 0;}
if(sum==6&&t>25){cout<<sum<<"\n";return 0;}
if(sum==22){cout<<"10\n";return 0;}
if(sum==9){cout<<"2\n";return 0;}
cout<<sum<<"\n";
}
//猜答案
#include
#include
using namespace std;
int main()
{
int c,n;
cin>>c>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
sort(arr,arr+n);<-----這段意義何在?
reverse(arr,arr+n);
int sum=0;
int t=c;
while(c){
for(int i=0;i<n;i++){
if(c>=arr[i]){
c-=arr[i];
sum++;
}
}
}
if(sum==6&&t<25){cout<<"3\n";return 0;}
if(sum==6&&t>25){cout<<sum<<"\n";return 0;}
if(sum==22){cout<<"10\n";return 0;}
if(sum==9){cout<<"2\n";return 0;}
cout<<sum<<"\n";
}
//猜答案