Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i.
He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A.
In how many ways can he make his selection?

-----Constraints-----
 - 1 \leq N \leq 50
 - 1 \leq A \leq 50
 - 1 \leq x_i \leq 50
 - N,\,A,\,x_i are integers.

-----Partial Score-----
 - 200 points will be awarded for passing the test set satisfying 1 \leq N \leq 16.

-----Input-----
The input is given from Standard Input in the following format:
N A
x_1 x_2 ... x_N

-----Output-----
Print the number of ways to select cards such that the average of the written integers is exactly A.

-----Sample Input-----
4 8
7 9 8 9

-----Sample Output-----
5

 - The following are the 5 ways to select cards such that the average is 8:
 - Select the 3-rd card.
 - Select the 1-st and 2-nd cards.
 - Select the 1-st and 4-th cards.
 - Select the 1-st, 2-nd and 3-rd cards.
 - Select the 1-st, 3-rd and 4-th cards.

Difficulty: EASY

Starter code:

Solutions:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

class UnionFind:

	def __init__(self, n):
		self.n = n
		self.parents = [-1] * n

	def find(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

	def size(self, x):
		return -self.parents[self.find(x)]

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))

def dijkstra_heap(s, edge, n):
	d = [10 ** 20] * n
	used = [True] * n
	d[s] = 0
	used[s] = False
	edgelist = []
	for (a, b) in edge[s]:
		heapq.heappush(edgelist, a * 10 ** 6 + b)
	while len(edgelist):
		minedge = heapq.heappop(edgelist)
		if not used[minedge % 10 ** 6]:
			continue
		v = minedge % 10 ** 6
		d[v] = minedge // 10 ** 6
		used[v] = False
		for e in edge[v]:
			if used[e[1]]:
				heapq.heappush(edgelist, (e[0] + d[v]) * 10 ** 6 + e[1])
	return d

def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append([i, cnt])
	if temp != 1:
		arr.append([temp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr

def lcm(x, y):
	return x * y // gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm, numbers, 1)

def gcd_list(numbers):
	return reduce(gcd, numbers)

def is_prime(n):
	if n <= 1:
		return False
	p = 2
	while True:
		if p ** 2 > n:
			break
		if n % p == 0:
			return False
		p += 1
	return True

def eratosthenes(limit):
	A = [i for i in range(2, limit + 1)]
	P = []
	while True:
		prime = min(A)
		if prime > sqrt(limit):
			break
		P.append(prime)
		i = 0
		while i < len(A):
			if A[i] % prime == 0:
				A.pop(i)
				continue
			i += 1
	for a in A:
		P.append(a)
	return P

def permutation_with_duplicates(L):
	if L == []:
		return [[]]
	else:
		ret = []
		S = sorted(set(L))
		for i in S:
			data = L[:]
			data.remove(i)
			for j in permutation_with_duplicates(data):
				ret.append([i] + j)
		return ret
(n, a) = map(int, input().split())
x = [i - a for i in map(int, input().split())]
dp = [[0 for j in range(4901)] for i in range(n)]
dp[0][2450] += 1
dp[0][x[0] + 2450] += 1
for i in range(1, n):
	for j in range(4901):
		dp[i][j] = dp[i - 1][j]
		if 0 <= j - x[i] < 4901:
			dp[i][j] += dp[i - 1][j - x[i]]
ans = dp[n - 1][2450] - 1
print(ans)


def abc044_c():
	(_, A) = map(int, input().split())
	X = list(map(lambda x: int(x) - A, input().split()))
	d = {0: 1}
	for x in X:
		for (k, v) in list(d.items()):
			d[k + x] = d.get(k + x, 0) + v
	ans = d[0] - 1
	print(ans)

def __starting_point():
	abc044_c()
__starting_point()


ma = lambda : map(int, input().split())
lma = lambda : list(map(int, input().split()))
tma = lambda : tuple(map(int, input().split()))
ni = lambda : int(input())
yn = lambda fl: print('Yes') if fl else print('No')
import collections
import math
import itertools
import heapq as hq

def ncr(n, r):
	ret = 1
	if n < r:
		return 0
	if n - r < r:
		r = n - r
	for i in range(1, r + 1):
		ret *= n - r + i
		ret //= i
	return ret
(n, a) = ma()
X = lma()
for i in range(n):
	X[i] -= a
co = collections.Counter(X)
ans = 0
mx = 49 * n
dp = [[0 for j in range(-mx, mx + 1)] for i in range(n + 1)]
dp[-1][0] = 1
for i in range(n):
	x = X[i]
	for j in range(-mx, mx + 1, 1):
		dp[i][j] += dp[i - 1][j] + dp[i - 1][j - x]
print(dp[n - 1][0] - 1)


(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
dp = [[[0] * (50 * (n + 10)) for _ in range(n + 10)] for _ in range(n + 10)]
dp[0][0][0] = 1
for i in range(n):
	for use in range(n):
		for total in range(n * a):
			if dp[i][use][total]:
				dp[i + 1][use][total] += dp[i][use][total]
				dp[i + 1][use + 1][total + x[i]] += dp[i][use][total]
ans = 0
for i in range(1, n + 1):
	ans += dp[n][i][a * i]
print(ans)


(n, a, *l) = map(int, open(0).read().split())
R = 2500
dp = [[0] * R * 2 for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
	for s in range(-R, R):
		dp[i + 1][s] = dp[i][s] + dp[i][s - l[i] + a]
print(dp[n][0] - 1)


(n, a) = map(int, input().split())
x = list(map(int, input().split()))
x = [i - a for i in x]
dic = {0: 1}
for i in x:
	for (j, k) in list(dic.items()):
		dic[i + j] = dic.get(i + j, 0) + k
print(dic[0] - 1)


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(N, A, *X) = list(map(int, read().split()))
	X = [x - A for x in X]
	base = 2500
	dp = [0] * 5001
	dp[base] = 1
	for i in range(N):
		(dp, dp_prev) = (dp[:], dp)
		for j in range(5001):
			if 0 <= j - X[i] <= 5000:
				dp[j] += dp_prev[j - X[i]]
	print(dp[base] - 1)
	return

def __starting_point():
	main()
__starting_point()


from collections import defaultdict
import io
(nim, mike) = map(int, input().split())
kite = list(map(int, input().split()))
for i in range(nim):
	kite[i] -= mike
qwe = defaultdict(int)
qwe[0] = 1
for o in kite:
	for (j, c) in list(qwe.items()):
		qwe[j + o] += c
print(qwe[0] - 1)


def solve():
	(N, A) = list(map(int, input().split()))
	X = list(map(int, input().split()))
	dp = [[0] * (A * N + 1) for _ in range(N + 1)]
	dp[0][0] = 1
	for (i, x) in enumerate(X):
		for j in reversed(list(range(1, i + 2))):
			for a in range(x, A * N + 1):
				dp[j][a] += dp[j - 1][a - x]
	print(sum((dp[i][A * i] for i in range(1, N + 1))))
solve()


(n, a) = list(map(int, input().split()))
x = [int(i) - a for i in input().split()]
dp = {0: 1}
for i in x:
	tmp = list(dp.items())
	for (key, value) in tmp:
		dp[key + i] = dp.get(key + i, 0) + value
print(dp[0] - 1)


def abc044_c():
	(_, A) = map(int, input().split())
	X = list(map(lambda x: int(x) - A, input().split()))
	d = {0: 1}
	for x in X:
		prev = list(d.items())
		for (val, cnt) in prev:
			d[val + x] = d.get(val + x, 0) + cnt
	ans = d[0] - 1
	print(ans)

def __starting_point():
	abc044_c()
__starting_point()


(n, a) = list(map(int, input().split()))
xxx = list(map(int, input().split()))
limit = a * n
dp = [[0] * (limit + 1) for i in range(n + 1)]
dp[0][0] = 1
for (i, x) in enumerate(xxx):
	if x > limit:
		continue
	for j in range(i, -1, -1):
		for k in range(limit - x, -1, -1):
			dp[j + 1][k + x] += dp[j][k]
print(sum((dp[i][i * a] for i in range(1, n + 1))))


def kiri(n, m):
	r_ = n / m
	if r_ - n // m > 0:
		return n // m + 1
	else:
		return n // m

def readInts():
	return list(map(int, input().split()))

def main():
	(n, a) = readInts()
	X = readInts()
	X = list(map(lambda i: i - a, X))
	dp = {0: 1}
	for i in X:
		for (k, v) in list(dp.items()):
			dp[i + k] = dp.get(i + k, 0) + v
	print(dp[0] - 1)

def __starting_point():
	main()
__starting_point()


from collections import defaultdict
(N, A) = map(int, input().split())
X = list(map(int, input().split()))
dp = defaultdict(dict)
dp[0][0] = 1
for x in X:
	newDP = defaultdict(dict)
	for (card, memo) in dp.items():
		for (k, v) in memo.items():
			if k in newDP[card]:
				newDP[card][k] += v
			else:
				newDP[card][k] = v
			if k + x in newDP[card + 1]:
				newDP[card + 1][k + x] += v
			else:
				newDP[card + 1][k + x] = v
	dp = newDP
ans = 0
for i in range(1, N + 1):
	if A * i in dp[i]:
		ans += dp[i][A * i]
print(ans)


NMAX = 55
(N, A) = list(map(int, input().split()))
X = list(map(int, input().split()))
dp = [[[0] * NMAX for s in range(3000)] for i in range(NMAX)]
dp[0][0][0] = 1
for i in range(N):
	for s in range(N * A + 1):
		for k in range(N + 1):
			if dp[i][s][k] == 0:
				continue
			dp[i + 1][s][k] += dp[i][s][k]
			dp[i + 1][s + X[i]][k + 1] += dp[i][s][k]
ans = 0
for k in range(1, N + 1):
	ans += dp[N][A * k][k]
print(ans)


from collections import Counter, defaultdict

def main():
	(N, A) = list(map(int, input().split()))
	X = [int(x) - A for x in input().split()]
	result = Counter([0])
	for x in X:
		dct = defaultdict(int)
		for (k, v) in list(result.items()):
			dct[k + x] += v
		result += dct
	print(result[0] - 1)

def __starting_point():
	main()
__starting_point()


(N, A) = (int(T) for T in input().split())
X = [int(T) for T in input().split()]
DP = [[[0] * (N + 1) for TS in range(0, 50 * N + 1)] for TI in range(0, N + 1)]
DP[0][0][0] = 1
for TI in range(0, N):
	for TS in range(0, 50 * N + 1):
		for TK in range(0, N + 1):
			if DP[TI][TS][TK] != 0:
				DP[TI + 1][TS][TK] += DP[TI][TS][TK]
				DP[TI + 1][TS + X[TI]][TK + 1] += DP[TI][TS][TK]
print(sum((DP[N][A * TA][TA] for TA in range(1, N + 1))))


(n, a) = map(int, input().split())
x = list(map(int, input().split()))
for i in range(n):
	x[i] -= a
dp = [[0 for i in range(100 * n + 1)] for j in range(n + 1)]
dp[0][50 * n] = 1
for i in range(n):
	for j in range(100 * n + 1):
		j2 = j - 50 * n
		num = x[i]
		if -50 * n <= j2 - num <= 50 * n:
			dp[i + 1][j] = dp[i][j] + dp[i][j - num]
		else:
			dp[i + 1][j] = dp[i][j]
print(dp[n][50 * n] - 1)


(N, A) = map(int, input().split())
X = list(map(int, input().split()))
Y = [x - A for x in X]
dp = {0: 1}
for y in Y:
	for (k, v) in list(dp.items()):
		dp[k + y] = dp.get(k + y, 0) + v
print(dp[0] - 1)


(N, A) = map(int, input().split())
x = list(map(int, input().split()))
maxint = 50 * N
dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for (xi, xe) in enumerate(x, 1):
	for j in range(xi + 1):
		for k in range(maxint + 1):
			dp[xi][j][k] = dp[xi - 1][j][k]
			if j >= 0 and k >= xe:
				dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
res = 0
for i in range(1, N + 1):
	res += dp[N][i][i * A]
print(res)


(N, A) = list(map(int, input().split()))
X = list(map(int, input().split()))
dp = [[[0 for _ in range(50 * (N + 2))] for _ in range(N + 2)] for _ in range(N + 2)]
dp[0][0][0] = 1
for k in range(N):
	for used in range(N):
		for i in range(50 * N):
			if dp[used][k][i] == 0:
				continue
			dp[used + 1][k + 1][i + X[k]] += dp[used][k][i]
			dp[used][k + 1][i] += dp[used][k][i]
ans = 0
for used in range(1, N + 1):
	ans += dp[used][N][used * A]
print(ans)


(n, a) = map(int, input().split())
nums = [int(i) - a for i in input().split()]
d = {0: 1}
for i in nums:
	s = [[j, d[j]] for j in d]
	for j in s:
		if j[0] + i in d:
			d[j[0] + i] += j[1]
		else:
			d[j[0] + i] = j[1]
print(d[0] - 1)


def c_tak_and_cards():
	from collections import defaultdict
	(N, A) = [int(i) for i in input().split()]
	X = [int(i) for i in input().split()]
	average = [x - A for x in X]
	dp = defaultdict(int)
	dp[0] = 1
	for y in average:
		for (k, v) in list(dp.items()):
			dp[k + y] += v
	return dp[0] - 1
print(c_tak_and_cards())


import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
(N, A) = map(int, input().split())
X = list(map(int, input().split()))
dp = [[0] * (N * A + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(0, N):
	for cnt in range(N, 0, -1):
		for val in range(N * A, -1, -1):
			if val - X[i] >= 0:
				dp[cnt][val] += dp[cnt - 1][val - X[i]]
ans = 0
for i in range(1, N + 1):
	ans += dp[i][i * A]
print(ans)


import numpy as np
(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
MAX = 50 * n
dp = np.zeros((n + 1, MAX + 1), np.int64)
dp[0][0] = 1
for e in x:
	dp[1:, e:] += dp[:-1, :-e]
cnt = np.arange(1, n + 1)
sm = cnt * a
ans = dp[cnt, sm].sum()
print(ans)


def abc044_c():
	(N, A) = map(int, input().split())
	X = list(map(lambda x: int(x) - A, input().split()))
	dp = [dict() for _ in range(N + 1)]
	dp[0][0] = 1
	for (i, x) in enumerate(X):
		dp[i + 1] = dp[i].copy()
		for (val, cnt) in dp[i].items():
			dp[i + 1][val + x] = dp[i].get(val + x, 0) + cnt
	ans = dp[N][0] - 1
	print(ans)

def __starting_point():
	abc044_c()
__starting_point()


import sys
(n, a) = list(map(int, input().split()))
cards = list(map(int, input().split()))
integers = [x - a for x in cards]
cards.append(a)
f = max(cards) * n
dp = [[0 for i in range(n + 1)] for j in range(2 * f + 1)]
for y in range(n + 1):
	for x in range(2 * f + 1):
		if y == 0 and x == f:
			dp[x][y] = 1
		elif y > 0 and (x - integers[y - 1] < 0 or x - integers[y - 1] > 2 * f):
			dp[x][y] = dp[x][y - 1]
		elif y > 0 and x - integers[y - 1] >= 0 and (x - integers[y - 1] <= 2 * f):
			dp[x][y] = dp[x - integers[y - 1]][y - 1] + dp[x][y - 1]
		else:
			dp[x][y] = 0
print(dp[f][n] - 1)


(n, a) = map(int, input().split())
x = list(map(lambda y: int(y) - a, input().split()))
w = 2 * n * max(max(x), a)
dp = [[0] * (w + 1) for _ in range(n + 1)]
dp[0][w // 2] = 1
for i in range(1, n + 1):
	for j in range(w + 1):
		dp[i][j] = dp[i - 1][j] + (dp[i - 1][j - x[i - 1]] if 0 <= j - x[i - 1] <= w else 0)
print(dp[n][w // 2] - 1)


import numpy as np
(n, a) = map(int, input().split())
x = list(map(int, input().split()))
sumx = sum(x)
dp = np.zeros((n, sumx + 1), dtype=np.int64)
for i in range(n):
	for j in range(i)[::-1]:
		dp[j + 1][x[i]:] += dp[j][:-x[i]]
	dp[0][x[i]] += 1
ans = 0
for i in range(n):
	if (i + 1) * a <= sumx:
		ans += dp[i][(i + 1) * a]
print(ans)


import numpy as np
(n, a) = map(int, input().split())
x = list(map(int, input().split()))
s = sum(x)
dp = np.zeros((n, s + 1), dtype=np.int64)
for i in range(n):
	for j in range(i)[::-1]:
		dp[j + 1][x[i]:] += dp[j][:-x[i]]
	dp[0][x[i]] += 1
t = 0
for k in range(n):
	if (k + 1) * a <= s:
		t += dp[k][(k + 1) * a]
print(t)


(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
dp = [[[0] * 2550 for _ in range(55)] for _ in range(55)]
dp[0][0][0] = 1
for i in range(n):
	for j in range(n + 1):
		for sm in range(n * a + 1):
			if dp[i][j][sm] == 0:
				continue
			dp[i + 1][j][sm] += dp[i][j][sm]
			dp[i + 1][j + 1][sm + x[i]] += dp[i][j][sm]
ans = 0
for k in range(1, n + 1):
	ans += dp[n][k][a * k]
print(ans)


(N, A) = map(int, input().split())
x = list(map(int, input().split()))
x = [i - A for i in x]
dp = [[0] * 50 * N * 2 for i in range(N + 1)]
dp[0][50 * N] = 1
for i in range(1, N + 1):
	for j in range(50 * N * 2):
		n = j - x[i - 1]
		if n >= 0 and n < 50 * N * 2:
			dp[i][j] = dp[i - 1][j] + dp[i - 1][n]
		else:
			dp[i][j] = dp[i - 1][j]
print(dp[N][50 * N] - 1)


(N, A) = map(int, input().split())
alist = list(map(int, input().split()))
blist = list(map(lambda x: x - A, alist))
sum_plus = 0
sum_minus = 0
for i in blist:
	if i > 0:
		sum_plus += i
	else:
		sum_minus += i
N = len(alist)
dp = [[0 for i in range(sum_plus - sum_minus + 1)] for j in range(N + 1)]
dp[0][0 - sum_minus] = 1
for i in range(N):
	for j in range(sum_plus - sum_minus + 1):
		if j - blist[i] <= sum_plus - sum_minus:
			dp[i + 1][j] = dp[i][j - blist[i]] + dp[i][j]
		else:
			dp[i + 1][j] = dp[i][j]
print(dp[N][0 - sum_minus] - 1)


import sys
readline = sys.stdin.readline

def main():
	(N, A) = map(int, readline().rstrip().split())
	X = list(map(int, readline().rstrip().split()))
	lim = max(X) * N
	X = [x - A for x in X]
	dp = [[0] * (2 * lim) for _ in range(N + 1)]
	dp[0][lim] = 1
	for i in range(1, N + 1):
		x = X[i - 1]
		for j in range(2 * lim):
			if 0 <= j - x < 2 * lim:
				dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x]
			else:
				dp[i][j] = dp[i - 1][j]
	print(dp[N][lim] - 1)

def __starting_point():
	main()
__starting_point()


import collections
(N, A) = [int(_) for _ in input().split()]
X = [int(_) for _ in input().split()]

def calc(W):
	M = len(W)
	dp = [collections.defaultdict(int) for _ in range(M + 1)]
	dp[0][0] = 1
	for (i, w) in enumerate(W):
		for j in range(i, -1, -1):
			for (k, v) in list(dp[j].items()):
				dp[j + 1][k + w] += v
	return dp
dpx = calc(X)
print(sum((dpx[i][i * A] for i in range(1, N + 1))))


import sys
import numpy as np
(n, a, *x) = map(int, sys.stdin.read().split())

def main():
	dp = np.zeros((n + 1, 2501), dtype=np.int64)
	dp[0, 0] = 1
	for i in range(n):
		dp[1:, x[i]:] += dp[:-1, :-x[i]].copy()
	i = np.arange(1, n + 1)
	print(dp[i, i * a].sum())
main()


(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(n):
	x[i] = x[i] - a
nx = n * n
dp = [[0] * (2 * nx + 1) for i in range(n + 1)]
dp[0][nx] = 1
for j in range(1, n + 1):
	jj = j - 1
	for t in range(2 * nx + 1):
		if t - x[jj] < 0 or 2 * nx < t - x[jj]:
			dp[j][t] = dp[j - 1][t]
		elif 0 < t - x[jj] and t - x[jj] < 2 * nx:
			dp[j][t] = dp[j - 1][t] + dp[j - 1][t - x[jj]]
		else:
			dp[j][t] = 0
print(dp[n][nx] - 1)


def main():
	(N, A) = map(int, input().split())
	X = list(map(int, input().split()))
	X = [x - A for x in X]
	ret = {0: 1}
	for xi in X:
		for (y, cnt) in list(ret.items()):
			ret[xi + y] = ret.get(xi + y, 0) + cnt
	print(ret[0] - 1)

def __starting_point():
	main()
__starting_point()


(N, A) = map(int, input().split())
ls1 = [0] + list(map(int, input().split()))
dp = [[[0 for k in range(2600)] for j in range(51)] for i in range(51)]
for i in range(51):
	dp[i][0][0] = 1
for j in range(1, N + 1):
	for k in range(1, j + 1):
		for s in range(2600):
			if s < ls1[j]:
				dp[j][k][s] = dp[j - 1][k][s]
			elif s >= ls1[j]:
				dp[j][k][s] = dp[j - 1][k - 1][s - ls1[j]] + dp[j - 1][k][s]
ans = 0
for k in range(1, N + 1):
	ans += dp[N][k][k * A]
print(ans)


(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
x = [i - a for i in x]
dp = [[0] * n * 50 * 2 for i in range(n + 1)]
dp[0][n * 50] = 1
for i in range(n):
	for j in range(n * 50 * 2):
		t = j - x[i]
		if 0 <= t < n * 50 * 2:
			dp[i + 1][j] = dp[i][j] + dp[i][t]
		else:
			dp[i + 1][j] = dp[i][j]
print(dp[n][n * 50] - 1)


def abc044_c():
	import numpy as np
	(n, a) = map(int, input().split())
	x = list(map(lambda x: int(x) - a, input().split()))
	x = np.array(x, dtype=np.int64)
	vrange = n * (a + np.max(x))
	dp = np.zeros((n + 1, 2 * vrange + 1), dtype=np.int64)
	dp[0, vrange] = 1
	for i in np.arange(n):
		dp[i + 1, :] += dp[i, :]
		if 0 < x[i]:
			dp[i + 1, x[i]:] += dp[i, :-x[i]]
		elif x[i] < 0:
			dp[i + 1, :x[i]] += dp[i, -x[i]:]
		else:
			dp[i + 1, :] += dp[i, :]
	ans = dp[n, vrange] - 1
	print(ans)

def __starting_point():
	abc044_c()
__starting_point()


(N, A) = map(int, input().split())
X = [int(x) for x in input().split()]
dp = [[0] * (N * A + 1) for _ in range(N + 1)]
dp[0][0] = 1
for x in X:
	for i in reversed(range(1, N + 1)):
		for j in reversed(range(N * A + 1)):
			if j < x:
				continue
			dp[i][j] += dp[i - 1][j - x]
ans = sum((dp[k][k * A] for k in range(1, N + 1)))
print(ans)


(n, a) = map(int, input().split())
x = list(map(int, input().split()))
for i in range(n):
	x[i] -= a
d = [0] * 6000
ans = 0
for dif in x:
	ans += d[-dif + 3000]
	if dif == 0:
		ans += 1
	if dif < 0:
		for i in range(6000):
			if 0 <= i + dif < 6000:
				d[i + dif] += d[i]
	else:
		for i in range(5999, -1, -1):
			if 0 <= i + dif < 6000:
				d[i + dif] += d[i]
	d[dif + 3000] = d[dif + 3000] + 1
print(ans)


(n, a) = map(int, input().split())
from collections import Counter
X = [int(x) - a for x in input().split()]
d = Counter([0])
for i in X:
	tmp = Counter()
	for (j, k) in d.items():
		tmp[i + j] += k
	d += tmp
print(d[0] - 1)


(N, A) = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))
xm = max(X)
xm = max(xm, A)
for i in range(N):
	X[i] -= A
dp = [[0] * (2 * N * xm + 1) for i in range(N + 1)]
dp[0][N * xm] = 1
for i in range(1, N + 1):
	for j in range(2 * N * xm + 1):
		if 0 <= j - X[i - 1] <= 2 * N * xm:
			dp[i][j] = dp[i - 1][j] + dp[i - 1][j - X[i - 1]]
		else:
			dp[i][j] = dp[i - 1][j]
print(dp[N][N * xm] - 1)


f = lambda : map(int, input().split())
(n, a) = f()
l = [i - a for i in f()]
dp = [[0] * 5000 for _ in range(51)]
Z = 2500
dp[0][Z] = 1
for i in range(n):
	for s in range(5000 - max(l[i], 0)):
		dp[i + 1][s] += dp[i][s]
		dp[i + 1][s + l[i]] += dp[i][s]
print(dp[n][Z] - 1)


(n, a) = map(int, input().split())
X = list(map(int, input().split()))
dp = [[0] * 2501 for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
	x = X[i]
	for j in range(n, 0, -1):
		for k in range(2501 - x):
			dp[j][k + x] += dp[j - 1][k]
ans = 0
for i in range(n):
	ans += dp[i + 1][(i + 1) * a]
print(ans)


(N, A) = map(int, input().split())
X = list(map(int, input().split()))
dp = [[[0] * 6000 for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for i in range(N):
	for j in range(N):
		for k in range(5000):
			if dp[i][j][k] == 0:
				continue
			dp[i + 1][j][k] += dp[i][j][k]
			dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]
C = 0
for i in range(N + 1):
	C += dp[N][i][i * A]
print(C - 1)


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(N, A, *X) = list(map(int, read().split()))
	X = [x - A for x in X]
	neg = pos = 0
	for x in X:
		if x > 0:
			pos += x
		else:
			neg += x
	M = pos - neg
	base = -neg
	dp = [[0] * (M + 1) for _ in range(N + 1)]
	dp[0][base] = 1
	for i in range(N):
		for s in range(M + 1):
			dp[i + 1][s] = dp[i][s]
			if 0 <= s - X[i] <= M:
				dp[i + 1][s] += dp[i][s - X[i]]
	print(dp[N][base] - 1)
	return

def __starting_point():
	main()
__starting_point()


(N, A) = map(int, input().split())
X = list(map(int, input().split()))
sumX = 2501
dp = [[[0 for _ in range(sumX)] for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for j in range(N):
	for k in range(N):
		for s in range(sumX):
			if dp[j][k][s] == 0:
				continue
			dp[j + 1][k][s] += dp[j][k][s]
			dp[j + 1][k + 1][s + X[j]] += dp[j][k][s]
ans = 0
for i in range(N + 1):
	ans += dp[N][i][i * A]
print(ans - 1)


NMAX = 55
T = 2500
(N, A) = list(map(int, input().split()))
X = list([int(x) - A for x in input().split()])
dp = [[0] * 5001 for i in range(NMAX)]
dp[0][T] = 1
for i in range(N):
	for s in range(5001):
		if s + X[i] > 5001 or dp[i][s] == 0:
			continue
		dp[i + 1][s] += dp[i][s]
		dp[i + 1][s + X[i]] += dp[i][s]
print(dp[N][T] - 1)


(n, a) = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n):
	A[i] = A[i] - a
B = []
c = 0
for i in range(n):
	if A[i] == 0:
		c = c + 1
	else:
		B.append(A[i])
n = len(B)
dp = [[0] * 5010 for i in range(n + 1)]
for i in range(1, n + 1):
	dp[i] = dp[i - 1][0:5010]
	dp[i][2505 + B[i - 1]] += 1
	for j in range(5010):
		if 0 <= j + B[i - 1] and j + B[i - 1] <= 5009:
			dp[i][j + B[i - 1]] += dp[i - 1][j]
ans = dp[n][2505]
print((ans + 1) * 2 ** c - 1)


import numpy as np
(n, a) = map(int, input().split())
x = list(map(int, input().split()))
dp = np.zeros((n + 1, n + 1, 3001)).astype(np.int64)
dp[0][0][0] = 1
for i in range(n):
	_x = x[i]
	for j in range(n):
		dp[i + 1, j + 1, _x:] += dp[i, j, :-_x]
		dp[i + 1, j, :] += dp[i, j, :]
ans = 0
for j in range(1, n + 1):
	ans += dp[n, j, j * a]
print(ans)


(n, a) = map(int, input().split())
x = list(map(int, input().split()))
t = [[[0] * (50 * (j + 1) + 1) for j in range(i + 2)] for i in range(n + 1)]
ans = 0
t[0][0][0] = 1
for i in range(1, n + 1):
	for j in range(i + 1):
		for k in range(50 * j + 1):
			if j >= 1 and k >= x[i - 1]:
				t[i][j][k] = t[i - 1][j - 1][k - x[i - 1]] + t[i - 1][j][k]
			else:
				t[i][j][k] = t[i - 1][j][k]
for i in range(1, n + 1):
	ans += t[n][i][i * a]
print(ans)


import sys

def main():
	mod = 1000000007
	inf = float('inf')
	sys.setrecursionlimit(10 ** 6)

	def input():
		return sys.stdin.readline().rstrip()

	def ii():
		return int(input())

	def mi():
		return list(map(int, input().split()))

	def mi_0():
		return [int(x) - 1 for x in input().split()]

	def lmi():
		return list(map(int, input().split()))

	def lmi_0():
		return list([int(x) - 1 for x in input().split()])

	def li():
		return list(input())
	(n, a) = mi()
	L = lmi()
	diff = [elm - a for elm in L]
	dp = [[0] * 5001 for _ in range(n + 1)]
	dp[0][2500] = 1
	for i in range(n):
		for j in range(5001):
			if dp[i][j]:
				dp[i + 1][j + diff[i]] += dp[i][j]
			dp[i + 1][j] += dp[i][j]
	print(dp[n][2500] - 1)

def __starting_point():
	main()
__starting_point()


import sys
from collections import defaultdict
(n, a, *x) = map(int, sys.stdin.read().split())
for i in range(n):
	x[i] -= a

def main():
	dp = defaultdict(int)
	dp[0] = 1
	for i in range(n):
		ndp = dp.copy()
		for (k, v) in dp.items():
			ndp[k + x[i]] += v
		dp = ndp
	print(dp[0] - 1)

def __starting_point():
	main()
__starting_point()


(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
import numpy as np
dp = np.zeros((n + 1, 2501), int)
dp[0, 0] = 1
for xi in x:
	for i in range(n - 1, -1, -1):
		dp[i + 1][xi:] += dp[i, :-xi]
ans = 0
for i in range(1, n + 1):
	ans += dp[i, i * a]
print(ans)


import numpy as np
(n, avea) = tuple([int(x) for x in input().split()])
x = list([int(x) for x in input().split()])
x = np.array(x)
x = x - avea
w = max(abs(min(x)), abs(max(x))) * n
dp = np.zeros((n + 1, 2 * w + 1), dtype=int)
dp[0, w] = 1
for i in range(1, n + 1):
	for j in range(2 * w + 1):
		if 0 <= j - x[i - 1] <= 2 * w:
			dp[i, j] = dp[i - 1, j] + dp[i - 1, j - x[i - 1]]
		else:
			dp[i, j] = dp[i - 1, j]
print(dp[n, w] - 1)


(N, A) = map(int, input().split())
x = list(map(int, input().split()))
maxX = max(max(x), A)
dp = [[[0 for _ in range(N * maxX + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for i in range(N):
	for j in range(N + 1):
		for k in range(N * A + 1):
			if dp[i][j][k] == 0:
				continue
			dp[i + 1][j][k] += dp[i][j][k]
			dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]
ans = 0
for i in range(1, N + 1):
	ans += dp[N][i][A * i]
print(ans)


(n, a) = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
dp = list(([0] * (n * a + 1) for _ in range(n + 1)))
dp[0][0] = 1
for x in l:
	for i in range(n, 0, -1):
		for j in range(n * a + 1):
			if x > j:
				continue
			dp[i][j] += dp[i - 1][j - x]
for i in range(n):
	ans += dp[i + 1][(i + 1) * a]
print(ans)


from collections import Counter
(N, A) = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = [x - A for x in X]
L = Counter()
L[0] = 1
for y in Y:
	for (key, value) in list(L.items()):
		L[key + y] += value
print(L[0] - 1)


def resolve():
	(N, A) = list(map(int, input().split()))
	X = [int(i) - A for i in input().split()]
	d = {0: 1}
	for x in X:
		for (_sum, count) in list(d.items()):
			d[_sum + x] = d.get(_sum + x, 0) + count
	print(d[0] - 1)
if '__main__' == __name__:
	resolve()


(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(n):
	x[i] -= a
dp = [[0] * 5001 for i in range(n + 1)]
dp[0][2500] = 1
for i in range(n):
	for j in range(5000):
		for k in range(2):
			if 0 <= j - k * x[i] <= 5000:
				dp[i + 1][j] += dp[i][j - k * x[i]]
print(dp[n][2500] - 1)


def main():
	(N, A) = list(map(int, input().split()))
	x = list(map(int, input().split()))
	dp = [[0] * (50 * N + 1) for _ in range(N + 1)]
	dp[0][0] = 1
	for k in range(N):
		for i in reversed(list(range(k + 1))):
			for j in range(50 * N + 1 - x[k]):
				dp[i + 1][j + x[k]] += dp[i][j]
	r = 0
	for i in range(1, N + 1):
		r += dp[i][i * A]
	return r
print(main())


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return list(map(int, input().split()))

def LIST():
	return list(map(int, input().split()))

def TUPLE():
	return tuple(map(int, input().split()))

def ZIP(n):
	return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 6
mod = 10 ** 9 + 7
(N, A) = MAP()
x = LIST()
big = []
small = []
cnt = 0
for y in x:
	if y == A:
		cnt += 1
	elif y < A:
		small.append(A - y)
	else:
		big.append(y - A)
big_possible = [0] * 2501
small_possible = [0] * 2501
big_possible[0] = 1
small_possible[0] = 1
for a in big:
	for i in range(2500 - a, -1, -1):
		if big_possible[i]:
			big_possible[i + a] += big_possible[i]
for b in small:
	for i in range(2500 - b, -1, -1):
		if small_possible[i]:
			small_possible[i + b] += small_possible[i]
ans = 1
for i in range(1, 2501):
	ans += small_possible[i] * big_possible[i]
ans *= 2 ** cnt
print(ans - 1)


(n, a) = map(int, input().split())
X = list(map(int, input().split()))
x = [i - a for i in X]
dp = [[0] * 5201 for i in range(n + 1)]
dp[0][2600] = 1
for (i, xi) in enumerate(x):
	for k in range(99, 5101):
		dp[i + 1][k + xi] += dp[i][k]
		dp[i + 1][k] += dp[i][k]
ans = dp[n][2600] - 1
print(ans)


(n, a) = map(int, input().split())
xlst = list(map(int, input().split()))
dp = [[0 for _ in range(5001)] for _ in range(n + 1)]
center = 2500
dp[0][center] = 1
for (i, x) in enumerate(xlst, 1):
	num = x - a
	for j in range(5001):
		dp[i][j] = dp[i - 1][j]
		if 0 <= j - num <= 5000:
			dp[i][j] += dp[i - 1][j - num]
print(dp[-1][center] - 1)


from collections import defaultdict
(n, a) = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
x = list(map(lambda x: x - a, x))
dic = defaultdict(int)
dic[0] = 1
for i in x:
	for (j, k) in list(dic.items()):
		dic[j + i] = dic.get(j + i, 0) + k
print(dic[0] - 1)


from collections import defaultdict
(N, A) = map(int, input().split())
X = list(map(int, input().split()))
X = [x - A for x in X]
d = defaultdict(int)
d[0] = 1
for x in X:
	for (k, v) in list(d.items()):
		d[k + x] += v
print(d[0] - 1)


(n, a) = map(int, input().split())
x = [int(x) for x in input().split()]
dp = [[0] * 2501 for _ in range(n + 1)]
for i in range(n + 1):
	for j in range(i - 1, -1, -1):
		if j == 0:
			dp[j + 1][x[i - 1]] += 1
		for k in range(2500, -1, -1):
			if dp[j][k] and k + x[i - 1] <= 2500:
				dp[j + 1][k + x[i - 1]] += dp[j][k]
ans = 0
for i in range(1, n + 1):
	ans += dp[i][i * a]
print(ans)


(_, a, *l) = map(int, open(0).read().split())
d = {0: 1}
for i in l:
	for (k, v) in d.copy().items():
		d[i - a + k] = d.get(i - a + k, 0) + v
print(d[0] - 1)


(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
MAX = 50 * n
dp = [[[0] * (MAX + 1) for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for (i, e) in enumerate(x, 1):
	for j in range(i):
		for k in range(MAX + 1):
			dp[i][j][k] += dp[i - 1][j][k]
	for j in range(i):
		for k in range(MAX - e + 1):
			dp[i][j + 1][k + e] += dp[i - 1][j][k]
ans = 0
for cnt in range(1, n + 1):
	sm = cnt * a
	ans += dp[n][cnt][sm]
print(ans)


(N, A) = (int(T) for T in input().split())
X = [int(T) - A for T in input().split()]
DP = [[0] * (2 * (50 * N) + 1) for TI in range(0, N + 1)]
DP[0][50 * N] = 1
for TI in range(0, N):
	for TS in range(0, 2 * 50 * N + 1):
		if DP[TI][TS] != 0:
			DP[TI + 1][TS] += DP[TI][TS]
			DP[TI + 1][TS + X[TI]] += DP[TI][TS]
print(DP[N][50 * N] - 1)


(n, a) = list(map(int, input().split()))
X = tuple(map(int, input().split()))
dp = [[[0] * 2550 for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i in range(n):
	for j in range(n):
		for s in range(n * a + 1):
			if dp[i][j][s] == 0:
				continue
			dp[i + 1][j][s] += dp[i][j][s]
			dp[i + 1][j + 1][s + X[i]] += dp[i][j][s]
ans = 0
for k in range(1, n + 1):
	ans += dp[n][k][k * a]
print(ans)


(N, A) = list(map(int, input().split()))
lst = [int(x) - A for x in input().split()]
dp = [[0] * (100 * N + 1) for _ in range(N + 1)]
dp[0][50 * N] = 1
for i in range(N):
	for j in range(50, 100 * N + 1 - 50):
		dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]]
print(dp[N][50 * N] - 1)


(N, A) = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0] * 2501 for i in range(N + 1)] for k in range(N + 1)]
dp[0][0][0] = 1
for j in range(N):
	for k in range(N):
		for i in range(2501):
			if dp[j][k][i] == 0:
				continue
			dp[j + 1][k][i] += dp[j][k][i]
			dp[j + 1][k + 1][i + x[j]] += dp[j][k][i]
ans = 0
for j in range(N + 1):
	ans += dp[N][j][j * A]
print(ans - 1)