#include using namespace std; #define int long long #define pb push_back #define fi first #define se second #define rep(i,s,n) for(int i = s;i=(s);i--) #define all(v) (v).begin(),(v).end() #define chmin(a,b) a=min((a),(b)) #define chmax(a,b) a=max((a),(b)) #define endl '\n' #define IOS() ios_base::sync_with_stdio(0);cin.tie(0) typedef long long ll; typedef pairpint; typedef vectorvint; const ll MOD=1000000007,INF=1e18; int T,N; int t[100010]; mapmp; int ans=INF; void solve(int cnt,vint& v){ if(mp[v])return; mp[v]=1; if(cnt==N){ rep(i,0,N){ if(v[i]==0)chmin(ans,i); if(i==N-1){ chmin(ans,N); return; } } } rep(i,0,N){ if(v[i]+t[cnt]>T)continue; if(v[i]==0){ v[i]+=t[cnt]; solve(cnt+1,v); v[i]-=t[cnt]; return; }else{ v[i]+=t[cnt]; solve(cnt+1,v); v[i]-=t[cnt]; if(i==N-1)return; } } } signed main() { IOS(); cin>>T>>N; rep(i,0,N)cin>>t[i]; vint v(N); solve(0,v); cout<