//Jakub Staroń
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstdio>

#ifdef COMPILING_HOME
#define DEBUG_MODE
#define HAVE_NEW_STANDARD
#endif

#ifdef HAVE_NEW_STANDARD
#include <unordered_map>
#include <unordered_set>
#else
#include <tr1/unordered_map>
#include <tr1/unordered_set>
using namespace std::tr1;
#endif

#define hash_map      unordered_map
#define hash_multimap unordered_multimap
#define hash_set      unordered_set
#define hash_multiset unordered_multiset

using namespace std;

typedef char int8;
typedef unsigned char uint8;
typedef short int int16;
typedef unsigned short int uint16;
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;

typedef std::pair<int32,int32> int32_pair;
typedef std::pair<uint32, uint32> uint32_pair;
typedef std::pair<int64,int64> int64_pair;
typedef std::pair<uint64,uint64> uint64_pair;

typedef std::vector<bool> bit_vector;

#ifdef HAVE_NEW_STANDARD
#define let(a,b) auto a = (b)
#else
#define let(a,b) __typeof (b) a = (b)
#endif

#ifdef DEBUG_MODE
#define pause system("pause")
#define clear_screen system("cls")
#define print(x) cerr << #x << " = " << x << endl
#define label_print(label, value) cerr << label << ' ' << value << endl
#define debug(x) x
#define line cerr << "Line " << __LINE__ << endl
#include <cassert>
#else
#define pause
#define clear_screen
#define print(x)
#define label_print(label, value)
#define debug(x)
#define assert(x)
#define line
#endif

#define rep(i,x) for(uint32 i = 0 ; i < (x) ; i++)
#define for_range(i,begin,end) for( let(i, (begin) ) ; i != (end) ; ++i )
#define foreach(i, c) for_range(i, c.begin(), c.end())
#define abs(a) ( (a) < 0 ? -(a) : (a) )
#define all(c) (c).begin(),(c).end()
#define sort_all(x) sort( all(x) )
#define divide(a,b) ( ( (b)%(a) ) == 0 )
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)

#define min(a,b) ( (a) < (b)? (a) : (b) )
#define max(a,b) ( (a) > (b)? (a) : (b) )
#define min3(a,b,c) (  min((a), min((b),(c))) )
#define max3(a,b,c) (  max((a), max((b),(c))) )
#define sig(x) ( (x) == 0 ? 0 : ( (x) < 0 ? -1 : 1 ) )

const double epsilon = 1e-5;

template<class T>
void unique(std::vector<T>& v)
{
	sort_all(v);
	v.resize( std::unique(all(v)) - v.begin() );
}

ostream& newline(ostream& str)
{
	str.put('\n');
	return str;
}

template<typename T1, typename T2>
istream& operator>>(istream& stream, std::pair<T1, T2>& pair)
{
	stream >> pair.first >> pair.second;
	return stream;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& stream, const std::pair<T1, T2>& pair)
{
#ifdef DEBUG_MODE
	stream << "(" << pair.first << ", " << pair.second << ")";
#else
	stream << pair.first << ' ' << pair.second;
#endif
	return stream;
}

class Graf
{
public:
	typedef vector<uint32> list_type;

	void resize(uint32 k)
	{
		graf.resize(k);
	}

	void add(uint32 a, uint32 b)
	{
		graf[a].push_back(b);
		graf[b].push_back(a);
	}

	uint32 deg(uint32 k)
	{
		return graf[k].size();
	}

	list_type& obok(uint32 k)
	{
		return graf[k];
	}

	uint32 size()
	{
		return graf.size();
	}

private:
	vector<list_type> graf;
};

void print_binary(uint32 mask, uint32 n)
{
	for(int32 i = 0 ; i < n ; i++)
	{

		cout.put(  (mask & (1u << i) )? '1' : '0' );
	}
	cout << endl;
}

const uint8 infinity = 100;
const uint8 nope = 101;


class Application
{
public:
	Application()
	{
	}

	void Run()
	{
		WczytajDane();
		sort( all(C), std::greater<uint64>() );
		C.resize( min(N,M) );
		GenerateSub();
		
		//cout << "Wygenerowalem sub." << endl;

		D.resize(N);
		rep(i, N)		
			D[i].assign(size, nope);


	
		char result = BackTrack(0, size - 1);
		if(result == infinity)
		{
			cout << "NIE" << newline;
		}
		else
		{
			cout << uint32(result) << newline;
		}

	}

	char BackTrack(uint32 start, uint32 mask)
	{		
		print(start);
		if(start >= C.size())
			return infinity;

		uint8& result = D[start][mask];

		if(result != nope)
		{
			return result;
		}
		
		result = infinity;

		if(C[start] >= sub[mask])
		{
			result = 1;
		}
		else
		{
			uint32 c = 0;
			for(uint32 j = mask ; j > 0 ;  j = (j - 1) & mask, c++ )
			{
				if(C[start] >= sub[j])
				{
					result = min(result, 1 + BackTrack(start + 1, mask & ~j) );
				}
			}
		}
	

		return result;
	}

	void GenerateSub()
	{
		sub.resize(size);
		sub[0] = 0;

		uint32 mask = 0;		
		rep(i, size)
		{
			uint32 p = 0;
			for(uint32 j = i ; j & 1 ; p++)
				j >>= 1;

			if(p < N)
			{
				bool add = ((mask & (1u << p)) == 0);

				uint32 old_mask = mask;
				mask ^= (1u << p);
				if(add)
				{
					sub[mask] = sub[old_mask] + A[p];
				}
				else
				{
					sub[mask] = sub[old_mask] - A[p];
				}

				
				//print_binary(mask, N);
				//print(sub[mask]);
			}
		}
	}

	void WczytajDane()
	{
		cin >> N >> M;
		size = (1u << N);

		A.resize(N);
		C.resize(M);
		rep(i, N)
			cin >> A[i];

		rep(i, M)
			cin >> C[i];
	}

	uint32 N,M;
	uint32 size;

	vector<uint64> A;
	vector<uint64> C;
	vector<uint64> sub;

	vector< vector<uint8> > D;
};


int main()
{
	ios::sync_with_stdio(0);
	Application application;
	application.Run();
	return 0;
}