#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for (int i = (m); i < (int)(n); i++)
using ll = long long;
using vl = vector<ll>;
using P = pair<ll, int>;


ll solve(vl& A, map<P, ll>& m, ll x, int i) {
    if (i == int(A.size()) - 1) return 1;
    if (m.count(P(x, i))) return m[P(x, i)];
    ll d = x % A[i + 1];
    ll ret = solve(A, m, x - d, i + 1);
    if (d > 0) ret += solve(A, m, x + (A[i + 1] - d), i + 1);
    return m[P(x, i)] = ret;
}


int main() {
    // input
    ll N, X;
    cin >> N >> X;
    vl A(N);
    rep(i, N) cin >> A[i];

    // solve
    map<P, ll> m;
    ll ans = solve(A, m, X, 0);
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
char grid[15][15];

int numOfV(int x, int y){
	if(grid[x][y] != '#') return 0;
	int vertexs = 0;
	if(grid[x][y-1] != '#' && grid[x+1][y] != '#' && grid[x-1][y] != '#'){ vertexs += 2; /*cout<<"1"<<endl;*/}
	if(grid[x][y-1] != '#' && grid[x][y+1] != '#' && grid[x-1][y] != '#') { vertexs += 2;}// cout<<"2"<<endl;} 
	if(grid[x-1][y] != '#' && grid[x+1][y] != '#' && grid[x][y+1] != '#') { vertexs += 2;}// cout<<"3"<<endl;}
	if(grid[x][y-1] != '#' && grid[x][y+1] != '#' && grid[x+1][y] != '#') { vertexs += 2;}// cout<<"4"<<endl;}

	if(grid[x+1][y] == '#' && grid[x][y+1] == '#' && grid[x+1][y+1] != '#'){ vertexs++;}// cout<<"5"<<endl;}
	if(grid[x-1][y] == '#' && grid[x][y+1] == '#' && grid[x-1][y+1] != '#'){ vertexs++;}// cout<<"6"<<endl;}

	if(grid[x][y-1] == '#' && grid[x+1][y] == '#' && grid[x+1][y-1] != '#'){ vertexs++;}// cout<<"7"<<endl;}
	
	if(grid[x-1][y] == '#' && grid[x][y-1] == '#' && grid[x-1][y-1] != '#'){ vertexs++;}// cout<<"8"<<endl;}
	//if(grid[x+1][y] == '#' && grid[x][y-1] == '#' && grid[x+1][y-1] != '#'){ vertexs++; cout<<"9"<<endl;}

	if(grid[x+1][y] == '#' && grid[x][y+1] == '#' && grid[x-1][y] != '#' && grid[x][y-1] != '#'){ vertexs++;}//  cout<<"9"<<endl;}
	if(grid[x+1][y] == '#' && grid[x][y-1] == '#' && grid[x-1][y] != '#' && grid[x][y+1] != '#'){ vertexs++;}//  cout<<"10"<<endl;}
	if(grid[x][y-1] == '#' && grid[x-1][y] == '#' && grid[x+1][y] != '#' && grid[x][y+1] != '#'){ vertexs++;}//  cout<<"11"<<endl;}
	if(grid[x-1][y] == '#' && grid[x][y+1] == '#' && grid[x+1][y] != '#' && grid[x][y-1] != '#'){ vertexs++;}//  cout<<"12"<<endl;}

	return vertexs;
}

int main(){
	int n,w; cin>>n>>w;
	int vertexs = 0;
	int catCounter = 0;
	for(int i = 0; i<n; i++){
		for(int j = 0; j<w; j++){
			cin>>grid[i][j];
			if(grid[i][j] == '#') catCounter++;
		}
	}

	for(int i = 1; i<n-1; i++){
		for(int j = 1; j<w-1; j++){
			int noV = numOfV(i,j);
			//cout<<"i = "<<i<< " j = "<<j<<" v = "<< noV << endl;
			vertexs += noV;
		}
	}
	if(catCounter == 1) cout<<"4\n";
	else cout<<vertexs<<"\n";
}
