#include <stdio.h>

int t[50001];

int main( void )
{
	int i, j, n, m, c[20];
	
	scanf( "%d", &n );
	scanf( "%d", &m );
	
	for ( i = 0; i < m; i++ ) {
		scanf( "%d", &c[i] );
	}
	
	for ( i = 0; i < 50001; i++ )
		t[i] = -1;
	t[0] = 0;
	
	for ( i = 0; i < m; i++ )
		for ( j = c[i]; j <= n; j++ )
			if ( t[j] > (t[j - c[i]] + 1) || t[j] == -1 )
				t[j] = t[j - c[i]] + 1;
				
	printf( "%d\n", t[n] );
	
	return 0;
}