#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } const ll inf = 1e15; ll pw(ll x, int r){ ll ans = 1; for(int i = 0; i < r; i++){ if(inf/x < ans) return inf; } return ans; } void dfs(int i, vector &v, map &mp, ll sum, ll s){ if(i == v.size()){ if(mp.count(sum)) mp[sum]++; else mp[sum] = 1; return; } ll x = 1; for(int r = 1; r <= 30; r++){ if(s/v[i] < x) break; x *= v[i]; dfs(i+1, v, mp, sum+x, s); } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n; ll s; cin >> n >> s; vector a(n); for(int i = 0; i < n; i++) cin >> a[i]; if(n == 1){ int ans = 0; for(int r = 1; r <= 30; r++){ if(pw(a[0], r) <= s) ans++; } cout << ans << endl; return 0; } vector vl, vr; for(int i = 0; i < n; i++){ if(i*2 < n){ vl.push_back(a[i]); }else{ vr.push_back(a[i]); } } map mpl, mpr; dfs(0, vl, mpl, 0, s); dfs(0, vr, mpr, 0, s); map mp; ll sum = 0; for(auto [x, c]: mpr){ sum += c; mp[x] = sum; } ll ans = 0; for(auto [x, c]: mpl){ auto p = mp.upper_bound(s-x); if(p == mp.begin()) continue; p--; ans += c*p->second; } cout << ans << endl; }