/*
       shool : Cu Chi High School
       participant : Ngo Quoc Binh
*/
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cerr << #x << " = " << x << "\n";
#define vdebug(a) cerr << #a << " = "; for(auto x : a) cout << x << " "; cout << "\n";
#define TIME cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define hashmap unordered_map
#define hashset unordered_set
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rev(x) reverse(all(x))
#define sz(x) ((int)((x).size()))
#define max_arr(x) *max_element(all(x))
#define min_arr(x) *min_element(all(x))

#define pb push_back
#define pf push_front
#define PB pop_back
#define PF pop_front
#define en '\n'
#define ff first
#define ss second
#define task "wtf"

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve()
{
        int x,n;
        cin >> x >> n;
        vector<ull> c(n);
        for(int i = 0 ; i < n ; i++) cin >> c[i];

        sort(all(c));
        c.erase(unique(all(c)),c.end());

        vector<ull> dp(x + 1,0);
        dp[0] = 1;
        
        for(ull d : c)
        {
                for(int res = d ; res <= x ; res++)
                {
                        dp[res] += dp[res - d];
                }
        }

        cout << dp[x];
}

int main()
{
        fastIO

        solve();

        return 0;
}