CSES - Shared codeLink to this code: https://cses.fi/paste/d1447ba3a7b8ca245e01a7/
#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define mod 1000000007

#define ll long long int
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vll vector<long long>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>
#define si set<int>
#define sc set<char>

#define pb push_back
#define f first
#define s second
#define all(c) (c).begin(), (c).end()
#define rall(a) (a).rbegin(), (a).rend()

void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }



umll gen_subs(int l, int r, vll a) {
    int len = r - l + 1;
    umll res;

    // loop through all subsets
    for (int i = 0; i < (1 << len); i++) {
        ll sum = 0;
        for (int j = 0; j < len; j++) {
            if (i & (1 << j)) {
                sum += a[l + j];
            }
        }
        res[sum]++;
    }

    return res;
}

void solve() {
    ll n, x;
    cin >> n >> x;
    vll a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    umll L = gen_subs(0, n/2 - 1, a);
    umll R = gen_subs(n/2, n-1, a);

    ll ans= 0;

    for (auto i : L) {
        ans += i.s * R[x - i.f];
    }

    cout << ans << nl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin >> t;
    // while (t--)
        solve();

    return 0;
}