/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ?
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define AL(x) x.begin(),x.end()
#define pw(x) (1ull<<(x))
#define NMSL cout << "NMSL" << endl;
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x, y) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define debug3(x, y, z) cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define debug4(a, b, c, d) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define fio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in128 __int128_t
using namespace std;
const int N = 2e5+10;
const int INF = 0x7f7f7f7f;
const double EPS = 1e-3;
const long double PI = 3.14159265358979323846;
int n,p,ans=0;
int a[55];
map<pair<signed,int>,int>mp;
int DFS(signed x,int rest)
{
    if(mp[{x,rest}])
        return mp[{x,rest}];
    if(x<=0)
        return 1;
    int fake=rest;
    int ck=abs(rest);
    fake%=a[x];
    ck=ck-abs(fake)+a[x];
    mp[{x,rest}]+=DFS(x-1,fake);
    if(ck<a[x+1])
    {
        if(fake>0)
            mp[{x,rest}]+=DFS(x-1,fake-a[x]);
        else if(fake<0)
            mp[{x,rest}]+=DFS(x-1,fake+a[x]);
    }
    return mp[{x,rest}];
}
signed main()
{
    fio
    cin>>n>>p;
    for(int i=0; i<n; ++i)
        cin>>a[i];
    p%=a[n-1];
    ans+=DFS(n-2,p);
    if(p)
        ans+=DFS(n-2,p-a[n-1]);
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, x, a[100], b[100], c[100], dp[100][2][2];
signed main() {
	scanf("%lld%lld", &n, &x);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", &a[i]);
	for (int i = n, y = x; i >= 1; --i)
		b[i] += y/a[i], y %= a[i];
	for (int i = 1; i < n; ++i)
		c[i] = a[i+1]/a[i];
	c[n] = 1e15;
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; ++i)
		if (c[i]-1 == b[i]) {
			dp[i][0][0] = dp[i-1][0][0]+dp[i-1][1][0];
			dp[i][0][1] = dp[i-1][0][1]+dp[i-1][1][1];
			dp[i][1][1] = dp[i-1][0][0]+dp[i-1][1][0];
		} else {
			dp[i][0][0] = dp[i-1][0][0]+dp[i-1][1][0]+dp[i-1][0][1]+dp[i-1][1][1];
			dp[i][1][1] = dp[i-1][0][1]+dp[i-1][1][1];
			if (b[i]) dp[i][1][1] += dp[i-1][0][0]+dp[i-1][1][0];
		}
	printf("%lld\n", dp[n][0][0]);
	return 0;
}
