#include<bits/stdc++.h>
using namespace std;
int w,n,a[30],ans;
void dfs(int noww,int depth){
if(noww==0){ans++;return;}
if(noww<0 || depth>n) return;
dfs(noww-a[depth],depth+1);
dfs(noww,depth+1);
}
int main(){
cin>>w>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
dfs(w,0);
cout<<ans/2;
return 0;
}