#include <bits/stdc++.h>
using namespace std;
long long ans;
map<pair<int, int>, int> P;
int a[55], n, A, mid;
void dfs(int i, int flag, int m, int x, int d) {
  if (i == mid) {
    if (m == 0) return;
    if (flag == 1) {
      if (d == 0 && m == x) ans++;
      P[pair<int, int>(x - m, d)]++;
    } else {
      if (d == 0 && m == x) ans++;
      if (d == 0)
        ans += P[pair<int, int>(m - x, 0)];
      else
        ans += P[pair<int, int>(m - x - 1, A - d)];
    }
    return;
  }
  dfs(i + flag, flag, m, x, d);
  dfs(i + flag, flag, m + 1, x + (d + a[i]) / A, (d + a[i]) % A);
}
int main() {
  scanf("%d%d", &n, &A);
  mid = n / 2;
  int cnt = 0;
  for (int i = 0; i <= n; i++)
    if (i != mid) {
      scanf("%d", &a[i]);
      if (a[i] == A) {
        n--;
        cnt++;
        i--;
        if (i < mid) mid--;
      }
    }
  dfs(0, 1, 0, 0, 0);
  dfs(n, -1, 0, 0, 0);
  long long s = 1;
  for (int i = 0; i < cnt; i++, s <<= 1)
    ;
  if (ans == 0 && s != 1) ans = s - 1, s = 1;
  printf("%lld\n", ans * s);
}
