#include <iostream>
using namespace std;
int main()
{
int m, n;
cin >> m >> n;
int k = 0, a;
while (n--)
{
cin >> a;
if (m >= a)
m -= a;
else
k++;
}
cout << k;
return 0;
}