#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N;
ll X;
vector<ll> A;
map<pair<int, ll>, ll> memo;

ll dfs(int i, ll x) {
    if (x == 0) return 1;
    if (i == -1) return 0;
    if (i < N - 1 && A[i + 1] <= x) return 0;
    if (x % A[i] == 0) return 1;
    if (memo.count({i, x})) return memo[{i, x}];
    ll a = x / A[i];
    ll ret = 0;
    if (i == N - 1 || A[i] * a < A[i + 1]) {
        ret += dfs(i - 1, x - A[i] * a);
    }
    if (i == N - 1 || A[i] * (a + 1) < A[i + 1]) {
        ret += dfs(i - 1, A[i] * (a + 1) - x);
    }
    return memo[{i, x}] = ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> X;
    A.resize(N);
    for (auto& x : A) cin >> x;
    cout << dfs(N - 1, X) << endl;
}
#include<bits/stdc++.h>
using namespace std;
char s[101][101];
int ans;
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++)
		scanf("%s",s[i]+1);
	for(int i=1; i<n; i++) {
		bool ok=false;
		for(int j=1; j<=m; j++) {
			if(s[i][j]!=s[i+1][j]) {
				if(!ok) {
					ans++;
					ok=true;
				}
			} else ok=false;
		}
	}
	for(int i=1; i<m; i++) {
		bool ok=false;
		for(int j=1; j<=n; j++) {
			if(s[j][i]!=s[j][i+1]) {
				if(!ok) {
					ans++;
					ok=true;
				}
			} else ok=false;
		}
	}
	printf("%d\n",ans);
	return 0;
}