#include <iostream>
#include <algorithm>

using namespace std;

bool arr[100005] = { 0 };
int main()
{
	int g;
	cin >> g;
	int p;
	cin >> p;
	for (int i = 0; i < p; i++)
	{
		int t;
		cin >> t;
		bool good = false;
		for (int j = t-1; j >= 0; j--)
		{
			if (arr[j] == true)
				continue;
			arr[j] = true;
			good = true;
			break;
		}
		if (!good)
		{
			cout << i << endl;
			goto done;
		}
	}
	cout << p << endl;
done:
		return 0;

}