A new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).

Killjoy's account is already infected and has a rating equal to $x$. Its rating is constant. There are $n$ accounts except hers, numbered from $1$ to $n$. The $i$-th account's initial rating is $a_i$. Any infected account (initially the only infected account is Killjoy's) instantly infects any uninfected account if their ratings are equal. This can happen at the beginning (before any rating changes) and after each contest. If an account is infected, it can not be healed.

Contests are regularly held on Codeforces. In each contest, any of these $n$ accounts (including infected ones) can participate. Killjoy can't participate. After each contest ratings are changed this way: each participant's rating is changed by an integer, but the sum of all changes must be equal to zero. New ratings can be any integer.

Find out the minimal number of contests needed to infect all accounts. You can choose which accounts will participate in each contest and how the ratings will change.

It can be proven that all accounts can be infected in some finite number of contests.


-----Input-----

The first line contains a single integer $t$ $(1 \le t \le 100)$ — the number of test cases. The next $2t$ lines contain the descriptions of all test cases.

The first line of each test case contains two integers $n$ and $x$ ($2 \le n \le 10^3$, $-4000 \le x \le 4000$) — the number of accounts on Codeforces and the rating of Killjoy's account.

The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ $(-4000 \le a_i \le 4000)$ — the ratings of other accounts.


-----Output-----

For each test case output the minimal number of contests needed to infect all accounts.


-----Example-----
Input
3
2 69
68 70
6 4
4 4 4 4 4 4
9 38
-21 83 50 -59 -77 15 -71 -78 20

Output
1
0
2



-----Note-----

In the first test case it's possible to make all ratings equal to $69$. First account's rating will increase by $1$, and second account's rating will decrease by $1$, so the sum of all changes will be equal to zero.

In the second test case all accounts will be instantly infected, because all ratings (including Killjoy's account's rating) are equal to $4$.

Difficulty: MEDIUM

Solutions:
y = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, x) = y()
	a = [*y()]
	if all((i == x for i in a)):
		print(0)
		continue
	if x in a or sum(a) == x * n:
		print(1)
		continue
	print(2)


t = int(input())
for w in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	pr = True
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			pr = False
			break
	if pr and a[0] == x:
		print(0)
		continue
	pr = False
	for i in range(n):
		if a[i] == x:
			pr = True
			break
	if pr:
		print(1)
		continue
	s = 0
	for q in a:
		s += q
	if n * x == s:
		print(1)
	else:
		print(2)


import sys
from collections import deque
from math import ceil, sqrt, gcd, factorial, log
from bisect import bisect_right, bisect_left
mod = 1000000007
INF = 10 ** 18
NINF = -INF

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

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

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

def modi(x):
	return pow(x, mod - 2, mod)

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

def write(l):
	for i in l:
		print(i, end=' ')
	print()
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if a == [x] * n:
		print(0)
		continue
	if sum(a) == x * n:
		print(1)
		continue
	if x in a:
		print(1)
		continue
	print(2)


gans = []
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	u = sorted(list(map(int, input().split())))
	sm = sum(u)
	if u[0] == u[-1] == x:
		gans.append(0)
	elif sm % n == 0 and sm // n == x or x in u:
		gans.append(1)
	else:
		gans.append(2)
print('\n'.join(map(str, gans)))


T = int(input())
for _ in range(T):
	(N, X) = map(int, input().split())
	A = [int(a) for a in input().split()]
	if A.count(X) == N:
		print(0)
	elif sum(A) == N * X or A.count(X) > 0:
		print(1)
	else:
		print(2)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

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

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, x) = value()
	a = array()
	need = [x - i for i in a]
	if len(set(a)) == 1:
		if a[0] == x:
			print(0)
		else:
			print(2)
	elif x in a or sum(need) == 0:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	count = 0
	for i in a:
		if i == x:
			count += 1
	if count == n:
		print(0)
		continue
	if count > 0:
		print(1)
		continue
	total = 0
	for i in a:
		total += x - i
	if total == 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	l = list(map(int, input().split()))
	countx = 0
	netsum = 0
	for i in l:
		if i == x:
			countx += 1
		netsum += x - i
	if countx == n:
		print(0)
	elif netsum == 0 or countx != 0:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(lambda y: int(y) - x, input().split()))
	s = sum(a)
	c = a.count(0)
	if not any(a):
		print(0)
	elif s == 0 or c:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	[n, x] = [int(tok) for tok in input().split()]
	a = [int(tok) for tok in input().split()]
	if all((ai == x for ai in a)):
		print(0)
	elif sum(a) == n * x:
		print(1)
	elif sum((ai == x for ai in a)) >= 1:
		print(1)
	else:
		print(2)


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	(n, kk) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	count = 0
	for i in range(n):
		if a[i] == kk:
			count += 1
	if count == n:
		print(0)
	elif count >= 1:
		print(1)
	else:
		ans = 0
		for i in range(n):
			if a[i] < kk:
				ans += kk - a[i]
			if a[i] > kk:
				ans -= a[i] - kk
		if ans == 0:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	if sum(A) == n * k:
		for a in A:
			if a != k:
				print(1)
				break
		else:
			print(0)
	elif k in A:
		print(1)
	else:
		print(2)


for Case in ' ' * int(input()):
	(n, x) = map(int, input().split())
	a = [int(s) for s in input().split()]
	if all([i == x for i in a]):
		print(0)
	elif sum(a) == x * n or x in a:
		print(1)
	else:
		print(2)


t = int(input())
n = []
x = []
a = []
for i in range(t):
	(ni, xi) = map(int, input().split())
	k = list(map(int, input().split()))
	n.append(ni)
	x.append(xi)
	a.append(k)

def fun(n, x, a):
	su = 0
	flag = 1
	nom = 0
	for i in range(n):
		su += a[i] - x
		if a[i] != x:
			flag = 0
		if a[i] == x:
			nom = 1
	if flag:
		return 0
	else:
		if nom == 1:
			return 1
		if su == 0:
			return 1
		else:
			return 2
for i in range(t):
	r = fun(n[i], x[i], a[i])
	print(r)


from sys import stdin
N = int(stdin.readline())
for case in range(N):
	(n, x) = map(int, stdin.readline().split())
	array = [int(i) for i in stdin.readline().split() if int(i) != x]
	difference = n - len(array)
	if sum(array) == x * len(array):
		if len(array) == 0:
			print(0)
		else:
			print(1)
	elif difference == 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if a == [x] * n:
		print(0)
	elif sum((i - x for i in a)) == 0 or x in a:
		print(1)
	else:
		print(2)


def voiD():
	(a, b) = (1, 1)
	if a == b:
		return 0
	return 1
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = [int(j) for j in input().split()]
	p = 0
	n = 0
	o = False
	for i in l:
		if i > x:
			p += i - x
		elif i < x:
			n += x - i
		else:
			o = True
	if p + n == 0:
		print(0)
	elif o or p == n:
		print(1)
	else:
		print(2)


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, x) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	ans = []
	for ele in arr:
		ans.append(x - ele)
	k = ans.count(0)
	if k == n:
		print(0)
	elif k > 0:
		print(1)
	elif sum(ans) == 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sum((i - x for i in a))
	q = set(a)
	if s == 0:
		print(1 if len(q) - 1 else 0)
	else:
		print(1 if x in q else 2)


t = int(input())
from math import sqrt
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	la = []
	ha = 0
	flag = 0
	for i in range(n):
		if x - l[i] != 0:
			la.append(x - l[i])
			ha += la[-1]
		else:
			flag = 1
	if la == []:
		print(0)
	elif ha == 0:
		print(1)
	elif flag == 1:
		print(1)
	else:
		print(2)


n = int(input())
for _ in range(n):
	(n, x) = [int(v) for v in input().split()]
	accts = [int(v) for v in input().split()]
	diff = [x - a for a in accts if x - a != 0]
	if not diff:
		print(0)
		continue
	if x in accts:
		print(1)
		continue
	neg = pos = 0
	for v in diff:
		if v < 0:
			neg -= v
		elif v > 0:
			pos += v
	if neg == pos:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(item) for item in input().split()]
	all_same = True
	has_same = False
	for item in a:
		if item != x:
			all_same = False
		if item == x:
			has_same = True
	if all_same:
		print(0)
		continue
	if sum(a) == x * n or has_same:
		print(1)
		continue
	print(2)


def solve(n, x, ratings):
	m = ratings.count(x)
	if m == n:
		return 0
	if m:
		return 1
	if sum(ratings) == n * x:
		return 1
	return 2
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ratings = list(map(int, input().split()))
	print(solve(n, x, ratings))


def solve(arr, x):
	if arr.count(x) == len(arr):
		return 0
	diff = sum((v - x for v in arr))
	cnt = arr.count(x)
	if diff == 0:
		return 1
	if cnt:
		return 1
	return 2
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	(*arr,) = map(int, input().split())
	print(solve(arr, x))


import sys
t = int(sys.stdin.readline().strip())
for i in range(t):
	(n, x) = map(int, sys.stdin.readline().split())
	line = list(map(int, sys.stdin.readline().split()))
	top = 0
	bot = 0
	if line.count(x) == n:
		print(0)
		continue
	elif line.count(x) > 0:
		print(1)
		continue
	for j in range(n):
		if line[j] < x:
			bot += x - line[j]
		if line[j] > x:
			top += line[j] - x
	if bot == top:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	if set(l) == {x}:
		print(0)
	else:
		s = 0
		f = 0
		for i in range(n):
			s = s + l[i] - x
			if l[i] == x:
				f = 1
		if s == 0 or f:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	left_sum = 0
	for i in arr:
		if i < x:
			left_sum += abs(x - i)
	right_sum = 0
	for i in arr:
		if i > x:
			right_sum += abs(i - x)
	only_x = False
	for i in arr:
		if i == x:
			only_x = True
			break
	if left_sum == 0 and right_sum == 0:
		print(0)
	elif right_sum == left_sum or only_x:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if l.count(x) == len(l):
		print(0)
	elif l.count(x) > 0 or sum(l) == n * x:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def fun(arr, n, x):
	cnt = 0
	sm = 0
	for i in range(n):
		cnt += arr[i] == x
		sm += arr[i]
	if cnt == n:
		return 0
	if cnt > 0:
		return 1
	if sm == n * x:
		return 1
	return 2
t = inp()
while t > 0:
	(n, x) = invr()
	arr = inlt()
	print(fun(arr, n, x))
	t -= 1


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 100000007
for _ in range(vary(1)):
	(n, x) = vary(2)
	num = array_int()
	flag = 0
	if len(set(num)) == 1 and num[0] == x:
		print(0)
		continue
	sum = 0
	for i in range(n):
		if num[i] == x and flag == 0:
			flag = 1
			break
		sum += num[i] - x
	if sum == 0 or flag == 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	same = 0
	if k in a:
		same = 1
	if len(set(a)) == 1 and a[0] == k:
		print(0)
	else:
		ch = 0
		for i in a:
			ch += i - k
		if ch == 0 or same > 0:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	(sum, same) = (0, 0)
	for i in a:
		sum += x - i
		if i == x:
			same += 1
	if same == n:
		print(0)
	elif same > 1:
		print(1)
	elif same == 0 and sum == 0:
		print(1)
	elif same == 0:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	(*a,) = map(int, input().split())
	seta = set(a)
	if len(seta) == 1 and x in seta:
		print(0)
		continue
	if sum(a) == n * x or x in seta:
		print(1)
		continue
	else:
		print(2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a = [i - k for i in a]
	flag = False
	f1 = False
	for i in a:
		if i != 0:
			flag = True
		else:
			f1 = True
	s = sum(a)
	if flag == True:
		if s == 0 or f1 == True:
			print(1)
		else:
			print(2)
	else:
		print(0)


def testcase():
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	if arr.count(x) == n:
		print(0)
	else:
		mark = [False for _ in arr]
		for i in range(n):
			if arr[i] == x:
				mark[i] = True
		marks = mark.count(True)
		total = sum(arr)
		if x == 0:
			if marks > 0 or total == 0:
				print(1)
			else:
				print(2)
		elif marks > 0 or total / x == n:
			print(1)
		else:
			print(2)
	return
t = int(input())
for _ in range(t):
	testcase()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def solve():
	(n, x) = sep()
	ar = lis()
	c = ar.count(x)
	if c == 0:
		k = sum(ar)
		if k == n * x:
			print(1)
		else:
			print(2)
	elif c == n:
		print(0)
	else:
		print(1)
testcase(int(inp()))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = [int(i) for i in input().split()][:n]
	s = list(set(l))
	if len(s) == 1 and s[0] == x:
		print(0)
	else:
		cnt = sum(l)
		if cnt == n * x or l.count(x) > 0:
			print(1)
		else:
			print(2)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	rate = list(map(int, input().split()))
	for j in range(n):
		rate[j] -= x
	if sum(rate) == 0:
		flg = 0
		for k in range(n):
			if rate[k] != 0:
				flg = 1
				break
		print(flg)
	elif 0 in rate:
		print(1)
	else:
		print(2)


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	for y in a:
		if y != x:
			b.append(y)
	if len(b) == 0:
		return 0
	s = 0
	for y in b:
		s += x - y
	if s == 0 or x in a:
		return 1
	return 2
t = int(input())
i = 0
while i < t:
	print(solve())
	i += 1


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	if x in a and max(a) == min(a):
		print(0)
	elif x in a or sum(a) / n == x:
		print(1)
	else:
		print(2)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	sm = 0
	for i in l:
		sm += i - x
	if len(set(l)) == 1 and l[0] == x:
		print(0)
	elif x in l or sm == 0:
		print(1)
	else:
		print(2)


def solve(a, b, d):
	big = float('inf')
	small = float('-inf')
	diff = 0
	same = 0
	for i in range(a):
		if d[i] != b:
			same += 1
		if i < a - 1:
			if d[i] > b:
				diff -= b - d[i]
			else:
				diff += d[i] - b
	if same == 0:
		return 0
	if same != a:
		return 1
	return 1 if d[-1] + diff == b else 2

def main():
	t = int(input())
	for i in range(t):
		d = input()
		d = [int(i) for i in d.split()]
		a = d[0]
		b = d[1]
		d = input()
		d = [int(i) for i in d.split()]
		ans = solve(a, b, d)
		print(ans)
main()


t = int(input())
for a in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	hasX = False
	sumAtFirst = 0
	countX = 0
	for integer in a:
		sumAtFirst += x - integer
		if integer == x:
			hasX = True
			countX += 1
	if countX == n:
		print(0)
	elif sumAtFirst == 0:
		print(1)
	elif hasX:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	left = 0
	right = 0
	mid = 0
	for i in range(n):
		if a[i] < x:
			left += x - a[i]
		elif a[i] > x:
			right += a[i] - x
		else:
			mid += 1
	if left == 0 and right == 0:
		print(0)
	elif mid > 0 or left == right:
		print(1)
	else:
		print(2)


t = int(input())
while t > 0:
	t = t - 1
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	sum = ct = 0
	for i in range(len(lst)):
		if lst[i] == x:
			ct += 1
		sum += lst[i]
	if ct == n:
		print(0)
	elif sum == n * x or ct > 0:
		print(1)
	else:
		print(2)


t = int(input())

def solve(n, x, a):
	if all((x == a[i] for i in range(n))):
		return 0
	if sum(a) == n * x:
		return 1
	if any((x == a[i] for i in range(n))):
		return 1
	else:
		return 2
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(solve(n, x, a))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	(n, x) = RL()
	a = RLL()
	if set(a) == set([x]):
		print(0)
	elif sum(a) == x * n or x in a:
		print(1)
	else:
		print(2)


t = int(input())
while t != 0:
	(n, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	set1 = set()
	sum1 = 0
	flag = 0
	for i in range(len(list1)):
		temp = list1[i] - x
		if temp == 0:
			flag = 1
		sum1 += temp
		set1.add(temp)
	if flag == 1 and len(set1) == 1:
		print(0)
	elif flag == 1 or sum1 == 0:
		print(1)
	else:
		print(2)
	t -= 1


from sys import stdin, stdout

class Input:

	def __init__(self):
		self.lines = stdin.read().splitlines()
		self.idx = 0

	def line(self):
		try:
			return self.lines[self.idx]
		finally:
			self.idx += 1

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.idx < len(self.lines):
			yield self

class Problem:

	def __init__(self):
		self.oo = float('inf')

	def gcd(self, a, b):
		return a if b == 0 else self.gcd(b, a % b)

	def modpow(self, a, n, m):
		ans = 1
		while n:
			if n & 1:
				ans = ans * a % m
			n >>= 1
			a = a * a % m
		return ans

	def solve(self, n, x, a):
		infected = 0
		for c in a:
			if c == x:
				infected += 1
		remain = n - infected
		if remain == 0:
			print(0)
		elif infected > 0:
			print(1)
		else:
			r = 0
			for c in a:
				r += x - c
			if r == 0:
				print(1)
			else:
				print(2)
try:
	p = Problem()
	for tc in Input().known_tests():
		p.solve(*tc.array(), tc.array())
except Exception as e:
	import traceback
	traceback.print_exc(file=stdout)


t = int(input())
i = 0
while i < t:
	(n, k) = [int(j) for j in input().split()]
	mas = [int(j) for j in input().split()]
	flag = [0 for j in range(len(mas))]
	count = 0
	for j in range(len(mas)):
		if mas[j] == k:
			count += 1
			flag[j] = 1
	if count == len(mas):
		print(0)
	elif count != 0:
		print(1)
	else:
		sum_prom = 0
		for j in range(len(mas) - 1):
			sum_prom += k - mas[j]
			mas[j] = k
			flag[j] = 1
		if mas[-1] - sum_prom == k:
			print(1)
		else:
			print(2)
	i += 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if a.count(x) == n:
		print('0')
	elif a.count(x) > 0:
		print('1')
	elif sum(a) // n == x and sum(a) % n == 0:
		print('1')
	else:
		print('2')


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A = [a - x for a in A]
	flag1 = False
	flag2 = True
	for a in A:
		if a != 0:
			flag2 = False
		else:
			flag1 = True
	if flag2:
		print(0)
		continue
	if flag1:
		print(1)
	elif sum(A) == 0:
		print(1)
	else:
		print(2)


[(lambda N, R, n: (lambda a, b, c: print(0 if a == b == 0 else 1 if a == b or c else 2))(sum((R - i for i in n if i < R)), sum((i - R for i in n if i > R)), sum((1 for i in n if i == R))))(*map(int, input().split()), list(map(int, input().split()))) for t in range(int(input()))]


def main():
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	all_x = True
	one = False
	sm = 0
	for i in lst:
		if i != x:
			all_x = False
		if i == x:
			one = True
		sm += i - x
	if all_x:
		print(0)
	elif sm != 0 and (not one):
		print(2)
	else:
		print(1)
t = int(input())
for i in range(t):
	main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if x == a[0] and a.count(x) == n:
		print(0)
		continue
	(neg, pos) = (0, 0)
	for i in a:
		if i < x:
			neg += x - i
		else:
			pos += i - x
	if neg == pos or x in a:
		print(1)
	else:
		print(2)


import sys, os, io

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

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(n, x) = ria()
		a = ria()
		d = Counter(a)
		s = sum(a)
		if x in d:
			if d[x] == n:
				print(0)
			else:
				print(1)
		elif s == n * x:
			print(1)
		else:
			print(2)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	s = set(a)
	t = sum(a)
	if s == {x}:
		ans = 0
	elif t == n * x:
		ans = 1
	elif x in a:
		ans = 1
	else:
		ans = 2
	print(ans)


def match(kj, accounts):
	count = 0
	for k in accounts:
		if kj == k:
			count += 1
	return count

def average(accounts):
	return sum(accounts) / len(accounts)

def solve(n, kj, accounts):
	match_count = match(kj, accounts)
	avg = average(accounts)
	if match_count == n:
		return 0
	elif match_count > 0:
		return 1
	elif avg == kj:
		return 1
	return 2
cases = int(input())
for k in range(cases):
	(n, x) = [int(i) for i in input().split(' ')]
	accounts = [int(i) for i in input().split(' ')]
	print(solve(n, x, accounts))


import math
t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	diff = 0
	sdiff = 0
	flag = False
	for i in range(n):
		if arr[i] == x:
			flag = True
		diff += abs(arr[i] - x)
		sdiff += arr[i] - x
	if diff == 0:
		print(0)
	elif sdiff == 0 or flag:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(num, x) = map(int, input().split())
	l = list(map(int, input().split()))
	p = 0
	n = 0
	s = 0
	for i in l:
		if i > x:
			p += i - x
		elif i == x:
			s += 1
		else:
			n += x - i
	if s == num:
		print('0')
	elif s > 0 or p == n:
		print('1')
	else:
		print('2')


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	c = a.count(x)
	if c == n:
		print(0)
	elif c >= 1:
		print(1)
	else:
		d = 0
		for i in a:
			d += x - i
		if d == 0:
			print(1)
		else:
			print(2)


for t in range(int(input())):
	o = list(map(int, input().split()))
	n = o[0]
	x = o[1]
	(flag, sum) = (int(0), int(0))
	a = list(map(int, input().split()))
	for i in range(n):
		if a[i] == x:
			flag += 1
		sum += a[i]
	if flag == n:
		print(0)
	elif flag > 0 or (sum % n == 0 and sum // n == x):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	eq = pos = neg = ans = 0
	for i in a:
		if i < x:
			neg += x - i
		elif i > x:
			pos += i - x
		else:
			eq += 1
	if pos or neg:
		if pos == neg:
			ans = 1
		elif eq:
			ans = 1
		else:
			ans = 2
	print(ans)


def process():
	(n, x) = list(map(int, input().split()))
	li = list(map(int, input().split()))
	if len(set(li)) == 1 and li[0] == x:
		return 0
	elif x in li or (sum(li) % n == 0 and sum(li) // n == x):
		return 1
	else:
		return 2
tests = int(input())
for i in range(tests):
	print(process())


import math
for z in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	if len(set(a)) == 1 and a[0] == x:
		print(0)
	elif x in a:
		print(1)
	elif sum(a) == x * n:
		print(1)
	else:
		print(2)


t = int(input())

def solve():
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	assert len(A) == n
	diff = [x - xx for xx in A]
	if sum(diff) == 0:
		for x in diff:
			if x != 0:
				return 1
		return 0
	for x in diff:
		if x == 0:
			return 1
	return 2
for _ in range(t):
	print(solve())


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	s = 0
	for j in l:
		if j == x:
			c += 1
		else:
			s += x - j
	if c == n:
		print(0)
	elif s == 0 or c > 0:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	tf = True
	tf1 = False
	for i in range(n):
		if x != a[i]:
			tf = False
		if a[i] == x:
			tf1 = True
		c += x - a[i]
	if tf:
		print(0)
	elif c == 0:
		print(1)
	elif tf1 == True:
		print(1)
	else:
		print(2)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(n, k) = In()
		l = list(In())
		count = 0
		if l.count(k) == n:
			print(0)
			return
		su = 0
		for x in range(n):
			su += l[x]
			if l[x] == k:
				count += 1
		if count > 0:
			print(1)
		elif su == n * k:
			print(1)
		else:
			print(2)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


ansl = []
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	al = list(map(int, input().split()))
	al.sort()
	if al[0] == x and al[-1] == x:
		ansl.append(0)
		continue
	if x * n == sum(al):
		ansl.append(1)
	elif x in al:
		ansl.append(1)
	else:
		ansl.append(2)
for a in ansl:
	print(a)


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(n, k) = map(int, stdin.readline().split())
	a = [int(x) for x in stdin.readline().split()]
	if len(set(a)) == 1 and a[0] == k:
		print(0)
		continue
	diff = [k - i for i in a]
	if sum(diff) == 0:
		print(1)
		continue
	if k in a:
		print(1)
		continue
	print(2)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
for xyz in range(0, int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	d = []
	f = True
	cnt = l.count(x)
	if cnt == n:
		print(0)
	elif cnt > 0:
		print(1)
	else:
		su = 0
		for i in l:
			su += i - x
		if su:
			print(2)
		else:
			print(1)


for t in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = True
	c = False
	ans = 2
	if sum(a) / n == x:
		ans = 1
	for i in a:
		if i != x:
			b = False
		if i == x:
			c = True
	if c:
		ans = 1
	if b:
		ans = 0
	print(ans)


from sys import stdin, stdout

def mark(A, B, K):
	for i in range(len(A)):
		if A[i] == K:
			A[i] = 1

def solve():
	(N, K) = list(map(int, stdin.readline().split()))
	arr = list(map(int, stdin.readline().split()))
	if arr.count(K) == N:
		return 0
	if K in arr:
		return 1
	s = 0
	for i in range(1, N):
		s += arr[i] - K
		arr[i] = K
	arr[0] += s
	if arr.count(K) == N:
		return 1
	return 2

def main():
	for _ in range(int(stdin.readline())):
		print(solve())
main()


rl = lambda : list(map(int, input().split()))
rn = lambda : int(input())
rns = lambda : map(int, input().split())
for _ in range(rn()):
	(n, k) = rns()
	l = rl()
	if l.count(k) == n:
		print(0)
	elif l.count(k) > 0 or sum([k - i for i in l]) == 0:
		print(1)
	else:
		print(2)


t = int(input())
while t:
	t -= 1
	i = input().split()
	n = int(i[0])
	x = int(i[1])
	arr = input().split()
	flag = 0
	sum = 0
	for i in arr:
		i = int(i)
		sum += i
		if i == x:
			flag = 1
	if not flag:
		if x * n == sum:
			print(1)
		else:
			print(2)
	else:
		for i in arr:
			i = int(i)
			if i ^ x:
				flag = 0
		if flag:
			print(0)
		else:
			print(1)


t = int(input())
for i in range(0, t):
	(a, b) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:a]
	ct = 0
	summ = 0
	for j in arr:
		if j == b:
			ct += 1
		summ = summ + (j - b)
	if ct == a:
		ans = 0
	elif summ == 0 or ct > 0:
		ans = 1
	else:
		ans = 2
	print(ans)


for _ in range(int(input())):
	(n, b) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	left = 0
	right = 0
	f = 0
	for i in arr:
		if i < b:
			left += b - i
		elif i > b:
			right += i - b
		else:
			f += 1
	if left == 0 and right == 0:
		print('0')
	elif f > 0 or left == right:
		print('1')
	else:
		print('2')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	neg = pos = 0
	one_found_infected = False
	all_infected = True
	s = 0
	for i in arr:
		if i != x:
			all_infected = False
		if i == x:
			one_found_infected = True
		s += i - x
	if all_infected:
		print(0)
	elif one_found_infected or s == 0:
		print(1)
	else:
		print(2)


def read_line():
	return list(map(int, input().split()))
T = int(input())
for _ in range(T):
	(n, x) = list(map(int, input().split()))
	l = read_line()
	t = 0
	all_eq = True
	has_eq = False
	for a in l:
		t += a - x
		if a != x:
			all_eq = False
		else:
			has_eq = True
	if all_eq:
		print(0)
	elif t == 0 or has_eq:
		print(1)
	else:
		print(2)


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))
import math

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math as M
MOD = 10 ** 9 + 7
from random import randint as R

def calc(n, x, A):
	R = []
	for i in range(n):
		R.append(x - A[i])
	R.sort()
	d = sum(R)
	bool = True
	diff = 0
	eq = 0
	for i in range(n):
		if A[i] != x:
			bool = False
		else:
			eq += 1
	if bool:
		return 0
	if d == 0 or eq > 0:
		return 1
	return 2
for _ in range(int(input())):
	(n, x) = INPUT()
	A = INPUT()
	print(calc(n, x, A))


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	sumo = 0
	for j in range(n):
		if a[j] == x:
			c = c + 1
		sumo = sumo + a[j] - x
	if c == n:
		print('0')
	elif c >= 1 and c < n:
		print('1')
	elif sumo == 0:
		print('1')
	else:
		print('2')


import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq
INF = 10 ** 20
MOD = 10 ** 9 + 7
ni = lambda : int(sys.stdin.readline().rstrip())
ns = lambda : map(int, sys.stdin.readline().rstrip().split())
na = lambda : list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda : list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda : sys.stdout.flush()

def main():
	t = ni()
	for _ in range(t):
		(n, x) = ns()
		a = na()
		aset = set(a)
		if len(aset) == 1 and x in aset:
			print(0)
			continue
		plmi = 0
		for ai in a:
			plmi += x - ai
		if plmi == 0 or x in aset:
			print(1)
			continue
		print(2)
main()


def is_already_infected(ratings, x):
	for i in ratings:
		if i != x:
			return False
	return True

def solve():
	(n, x) = [int(x) for x in input().split(' ')]
	ratings = [int(x) for x in input().split(' ')]
	if is_already_infected(ratings, x):
		print(0)
		return
	if x in ratings:
		print(1)
		return
	changes = 0
	for i in ratings:
		changes += i - x
	if changes == 0:
		print(1)
	else:
		print(2)
for i in range(int(input())):
	solve()


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	a = 0
	for i in range(n):
		a += m - ar[i]
	if ar.count(m) == n:
		print(0)
	elif a == 0 or ar.count(m) > 0:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	Sum = sum(arr)
	cnt = 0
	for i in arr:
		if i == x:
			cnt += 1
	if cnt == n:
		print(0)
	elif cnt >= 1 or Sum == n * x:
		print(1)
	else:
		print(2)


import sys
import math
from collections import *
from queue import *
from bisect import *
MOD = int(1000000000.0 + 7)
inf = float('inf')
ninf = float('-inf')
input = sys.stdin.readline

def ii():
	return list(map(int, input().strip().split()))
pr = print
for _ in range(int(input())):
	(n, x) = ii()
	arr = ii()
	if arr.count(x) == n:
		pr(0)
	elif x in arr or sum(arr) == x * n:
		pr(1)
	else:
		pr(2)


t = int(input())
for i in range(t):
	(num, aim) = map(int, input().split())
	l = tuple(map(int, input().split()))
	s = set(l)
	if s == set([aim]):
		print(0)
	elif aim in s or sum(l) == num * aim:
		print(1)
	else:
		print(2)


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if all((i == x for i in a)):
		print(0)
	else:
		average = sum(a) / n
		if x == average or x in a:
			print(1)
		else:
			print(2)
runs = int(input())
while runs > 0:
	solve()
	runs -= 1


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, inf) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	diff = [inf - v for v in a]
	flag = sm = 0
	for v in diff:
		if v != 0:
			flag = 1
		sm += v
	if flag == 0:
		print(0)
	elif inf in a or (flag == 1 and sm == 0):
		print(1)
	else:
		print(2)


tt = int(input())
for i in range(tt):
	(noOfaccounts, killJoysRating) = list(map(int, input().split()))
	accountsRating = list(map(int, input().split()))
	rightSum = 0
	leftSum = 0
	countOfInfected = 0
	for rating in accountsRating:
		if rating == killJoysRating:
			countOfInfected += 1
		elif rating < killJoysRating:
			leftSum += killJoysRating - rating
		else:
			rightSum += rating - killJoysRating
	if rightSum == 0 and leftSum == 0:
		print(0)
	elif countOfInfected > 0 or leftSum == rightSum:
		print(1)
	else:
		print(2)


from sys import stdin, stdout
import math
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	sume = 0
	counter = 0
	flag = 0
	for i in range(n):
		if arr[i] != k:
			sume += k - arr[i]
			counter += 1
		else:
			flag -= 1
	if counter == 0:
		print(0)
	elif sume == (n - counter) * k or flag <= -1:
		print(1)
	else:
		print(2)


def inp():
	return int(input())

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

def minp():
	return map(int, input().split())
for _ in range(inp()):
	(n, x) = minp()
	a = linp()
	i = 0
	num = 0
	b = 0
	d = True
	while i < n:
		if a[i] > x:
			b += a[i] - x
		elif a[i] == x:
			d = False
		else:
			num += x - a[i]
		i += 1
	if b + num == 0:
		print(0)
	elif not d or b == num:
		print(1)
	else:
		print(2)


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	flag = 0
	flag1 = 0
	for j in a:
		if j != x:
			flag = 1
		else:
			flag1 = 1
		c += j - x
	if flag == 0:
		print(0)
	elif c == 0 or flag1 == 1:
		print(1)
	else:
		print(2)


def func(a, x):
	ans = 0
	for i in a:
		ans += x - i
	return ans == 0
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if min(a) == max(a) == x:
		print(0)
	elif func(a, x) or x in a:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	(N, X) = [int(_) for _ in input().split()]
	A = [int(_) for _ in input().split()]
	if all([el == X for el in A]):
		print(0)
		continue
	s = 0
	for el in A:
		s += X - el
	if s == 0:
		print(1)
		continue
	nb_eqs = len([el for el in A if el == X])
	if nb_eqs:
		print(1)
		continue
	print(2)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	lt = [int(o) for o in input().split()]
	c = 0
	for i in lt:
		if i == k:
			c += 1
	if c == n:
		print(0)
	elif sum(lt) / n == k or c > 0:
		print(1)
	else:
		print(2)


for _ in ' ' * int(input()):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	print(0 if all([i == k for i in a]) else 1 if sum(a) == k * n or k in a else 2)


import math
from collections import deque
from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().strip().split(' '))
	arr = list(map(int, input().strip().split(' ')))
	diff = []
	for i in range(n):
		if x - arr[i] != 0:
			diff.append(x - arr[i])
	if len(diff) == 0:
		print(0)
	elif sum(diff) == 0 or x in arr:
		print(1)
	else:
		print(2)


import sys
import collections
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, X) = [int(x) for x in input().split()]
		A = [int(x) for x in input().split()]
		C = []
		for a in A:
			C.append(X - a)
		total = sum(C)
		if total == 0:
			ans = 0
			for a in A:
				if a != X:
					ans = 1
			print(ans)
		elif 0 in C:
			print(1)
		else:
			print(2)
main()


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	x = int(l[1])
	l = input().split()
	li = [int(i) for i in l]
	poss = 1
	for i in li:
		if i != x:
			poss = 0
			break
	if poss:
		print(0)
		continue
	poss = 0
	for i in li:
		if i == x:
			poss = 1
			break
	if poss:
		print(1)
		continue
	z = sum(li)
	if z == n * x:
		print(1)
		continue
	print(2)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	nums = list(map(int, input().split()))
	if all((i == x for i in nums)):
		print(0)
	elif sum(nums) == n * x or x in nums:
		print(1)
	else:
		print(2)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	(n, x) = li()
	a = li()
	b = []
	if len(set(a)) == 1 and a[0] == x:
		print(0)
	else:
		p = sum(a) / len(a)
		if p == x or x in a:
			print(1)
		else:
			print(2)
for _ in range(I()):
	solve()


t = int(input())
for _ in range(t):
	l1 = [int(x) for x in input().split()]
	(n, x) = (l1[0], l1[1])
	l2 = [int(x) for x in input().split()]
	diff = sum([y - x for y in l2])
	if l2.count(x) == len(l2):
		print(0)
	elif diff == 0:
		print(1)
	elif x in l2:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	array = [int(x) for x in input().split()]
	if len(set(array)) == 1 and array[0] == array[1] and (x == array[0]):
		print(0)
	elif x in array or sum(array) / n == float(x):
		print(1)
	else:
		print(2)


def solve(n, x, acc):
	count_x = sum([1 if a == x else 0 for a in acc])
	if count_x == n:
		return 0
	if count_x > 0 or n * x == sum(acc):
		return 1
	return 2
t = int(input())
for _ in range(t):
	(n, x) = tuple(map(int, input().strip().split()))
	acc = list(map(int, input().strip().split()))
	print(solve(n, x, acc))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = True
	for i in range(n):
		if a[i] != x:
			b = False
			break
	if b:
		print(0)
	else:
		for i in range(n):
			if a[i] == x or sum(a) == n * x:
				print(1)
				break
			elif i == n - 1:
				print(2)


import sys
input = sys.stdin.readline

def main():
	(n, x) = map(int, input().split())
	alst = list(map(int, input().split()))
	if alst.count(x) == n:
		print(0)
	elif sum(alst) == x * n:
		print(1)
	elif x in alst:
		print(1)
	else:
		print(2)
for _ in range(int(input())):
	main()


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	if arr.count(x) == n:
		print(0)
	else:
		my_list = []
		for i in arr:
			my_list.append(x - i)
		if sum(my_list) == 0 or 0 in my_list:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	x = 0
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for j in range(n):
		x = x + a[j]
	if k in a or k == x / n:
		if a.count(a[0]) == n and a[0] == k:
			print('0')
		else:
			print('1')
	else:
		print('2')


def main():
	(n, vir) = map(int, input().split(' '))
	grade = [i for i in map(int, input().split(' '))]
	if grade.count(vir) == n:
		return 0
	elif vir in grade and sum(grade) != vir * n:
		return 1
	elif sum(grade) == vir * n:
		return 1
	else:
		return 2
n = int(input())
res = []
for i in range(n):
	res.append(main())
for i in res:
	print(i)


from sys import stdin, stdout
from math import *
testing = True

def tp(s='\n'):
	if testing:
		stdout.write(s)

def main():
	t = int(stdin.readline())
	for _ in range(t):
		(n, k) = [int(i) for i in stdin.readline().split()]
		accounts = [int(i) for i in stdin.readline().split()]
		total = 0
		all_k = True
		any_k = False
		for i in range(n):
			if accounts[i] != k:
				all_k = False
			else:
				any_k = True
			total += accounts[i]
		if all_k:
			print(0)
		elif total == k * n or any_k:
			print(1)
		else:
			print(2)
main()


import sys
input = sys.stdin.readline
n = int(input())
for ii in range(n):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split() if i != '\n']
	diff = []
	for i in range(n):
		diff.append(x - a[i])
	if sum(diff) == 0:
		if set(diff) == {0}:
			print(0)
		else:
			print(1)
	elif x in a:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = [ele - x for ele in a]
	if a == [0] * n:
		print(0)
	elif 0 in a:
		print(1)
	elif sum(a) == 0:
		print(1)
	else:
		print(2)


import math
t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if all((val == x for val in a)):
		print('0')
	elif any((val == x for val in a)):
		print('1')
	elif sum((x - val for val in a)) == 0:
		print('1')
	else:
		print('2')
	t -= 1


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	s = 0
	q = list(set(a))
	if len(q) == 1 and q[0] == k:
		print('0')
	elif sum(a) / n == k or k in a:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = 0
	cnt = 0
	for i in arr:
		res += i - x
	if arr.count(x) == n:
		print(0)
	elif res == 0 or arr.count(x) > 0:
		print(1)
	else:
		print(2)


def kill(arr, k):
	ans = 0
	for i in arr:
		ans += k - i
	if arr.count(k) == len(arr):
		return 0
	if ans == 0:
		return 1
	if arr.count(k) >= 1:
		return 1
	return 2
for i in range(int(input())):
	(a, b) = map(int, input().strip().split())
	lst = list(map(int, input().strip().split()))
	print(kill(lst, b))


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = sum([t - x for t in arr])
	if arr.count(x) == len(arr):
		print(0)
	elif x in arr:
		print(1)
	elif d == 0:
		print(1)
	else:
		print(2)


import os
import sys
from io import BytesIO, IOBase
_str = str
BUFSIZE = 8192

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def inp():
	return sys.stdin.readline()

def mpint():
	return map(int, sys.stdin.readline().split(' '))

def itg():
	return int(sys.stdin.readline())

def solve():
	(n, x) = mpint()
	arr = tuple(mpint())
	c = arr.count(x)
	s = sum(arr)
	if c == n:
		return 0
	elif c or s == x == 0 or s / n == x:
		return 1
	return 2
for _ in range(itg()):
	print(solve())


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
import math
from math import *

def main():
	for t in range(int(input())):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		b = a.count(x)
		if b == n:
			print(0)
		elif b > 0:
			print(1)
		else:
			su = 0
			for i in range(n):
				if a[i] < x:
					su = su - abs(x - a[i])
				else:
					su = su + abs(x - a[i])
			if su == 0:
				print(1)
			else:
				print(2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
t = int(input())
for tt in range(t):
	(n, x) = nii()
	a = lnii()
	if a.count(x) == n:
		print(0)
		continue
	cnt = sum((i - x for i in a))
	if cnt == 0 or x in a:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lis = list(map(int, input().split()))
	if lis.count(m) == n:
		print(0)
	elif sum(lis) == m * n or lis.count(m) > 0:
		print(1)
	else:
		print(2)


T = int(input())
for t in range(T):
	n = input().split()
	x = int(n[1])
	n = int(n[0])
	a = input().split()
	sum = 0
	f = 0
	for i in a:
		if int(i) == x:
			f += 1
		sum += int(i)
	if f == n:
		print(0)
	elif f > 0 or sum / n == x:
		print(1)
	else:
		print(2)


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = int(input())

def solve():
	cnt = 0
	for i in range(n):
		if l[i] == x:
			cnt += 1
	if cnt == n:
		return 0
	suma = 0
	d = {}
	for i in l:
		d[i] = 1
	ch = 0
	for i in range(n):
		suma += x - l[i]
		if l[i] == x:
			ch = 1
	if d.get(x, -1) != -1:
		del d[x]
	if suma == 0:
		return 1
	elif ch == 1:
		return 1
	else:
		return 2
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	print(solve())


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	if all((b == x for b in a)):
		print(0)
	elif sum(a) == n * x or any((b == x for b in a)):
		print(1)
	else:
		print(2)


import sys, math, heapq, copy
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
mod = 1000000007

def get_int():
	return int(sys.stdin.readline().strip())

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

def get_float():
	return float(sys.stdin.readline().strip())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

def list_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))
t = get_int()
for _ in range(t):
	(n, x) = get_ints()
	l = list_ints()
	d = defaultdict(int)
	y = 0
	flag = 0
	for i in range(n):
		value = x - l[i]
		if value != 0:
			d[value] += 1
		if value == 0:
			flag = 1
		if i != n - 1:
			y += value
	if len(d) == 0:
		print(len(d))
	elif flag == 1:
		print(1)
	elif y >= 0 and l[n - 1] - y == x:
		print(1)
	elif y < 0 and l[n - 1] + abs(y) == x:
		print(1)
	else:
		print(2)


test = int(input())
for i in range(test):
	(n, x) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	count = 0
	for i in range(n):
		if a[i] == x:
			count += 1
	if count == n:
		print(0)
	elif count == 0:
		s = 0
		for i in range(n):
			s += a[i] - x
		if s == 0:
			print(1)
		else:
			print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = a.count(x)
	if sum(a) == n * x:
		if c == n:
			print(0)
		else:
			print(1)
	elif sum(a) % n == 0:
		if c >= 1:
			print(1)
		else:
			print(2)
	elif c >= 2:
		print(1)
	elif c == 1:
		s = sum(a)
		for i in range(n + 1):
			if (s - x * i) % (n - i) == 0:
				print(1)
				break
		else:
			print(2)
	else:
		print(2)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, permutations
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
localsys = 0
start_time = time.time()
nCr = lambda n, r: reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)

def ceill(n, x):
	return (n + x - 1) // x
T = 1

def solve():
	(n, k) = lint()
	a = lint()
	if len(set(a)) == 1 and a[0] == k:
		print(0)
	elif k in a or sum(a) == k * n:
		print(1)
	else:
		print(2)

def run():
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
run()
T = I() if T else 1
for _ in range(T):
	solve()
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


from collections import Counter, OrderedDict
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n, x) = gil()
	a = gil()
	a.sort()
	present = True if x in a else False
	if a[-1] == a[0] == x:
		print(0)
	else:
		s = sum([a[i] - x for i in range(n)])
		if present:
			print(1)
		elif s == 0:
			print(1)
		else:
			print(2)


t = int(input())
ns = []
xs = []
arrs = []
for _ in range(t):
	enter = input().split(' ')
	enter = [int(x) for x in enter]
	ns.append(enter[0])
	xs.append(enter[1])
	arrs.append([int(x) for x in input().split(' ')])
for i in range(t):
	n = ns[i]
	x = xs[i]
	arr = arrs[i]
	all_equal = True
	difference = 0
	is_in = False
	for a in arr:
		if x - a != 0:
			all_equal = False
		else:
			is_in = True
		difference += x - a
	if all_equal == True:
		print(0)
	elif difference == 0 or is_in == True:
		print(1)
	else:
		print(2)


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
import sys
letters = ascii_letters[:26]
input = stdin.readline

def can(arr):
	return not sum(arr) % n
for _ in range(int(input())):
	(n, need) = map(int, input().split())
	arr = list(map(int, input().split()))
	if all(map(lambda x: x == need, arr)):
		print(0)
	else:
		delta = 0
		for i in arr:
			delta += need - i
		if delta == 0:
			print(1)
		else:
			cnt = len([i for i in arr if i == need])
			if cnt > 0:
				print(1)
			else:
				print(2)


def main():
	t = eval(input())
	for cas in range(t):
		(n, x) = map(int, input().split())
		arr = list(map(int, input().split()))
		flag = True
		flagg = False
		tol = 0
		for i in arr:
			if i != x:
				flag = False
			else:
				flagg = True
			tol += i
		if flag:
			print(0)
		elif tol == x * n:
			print(1)
		elif flagg:
			print(1)
		else:
			print(2)
main()


def read_line(type=int):
	return list(map(type, input().split()))
t = int(input())
for _ in range(t):
	(n, x) = read_line()
	d = read_line()
	s = set(d)
	ans = 0
	diff = list(map(lambda i: i - x, d))
	if len(s) == 1 and x in s:
		ans = 0
	elif sum(diff) == 0:
		ans = 1
	elif x in d:
		ans = 1
	else:
		ans = 2
	print(ans)


T = int(input())
for _ in range(0, T):
	(n, kk) = map(int, input().split())
	s = [int(x) for x in input().split()]
	arr = list(set(s))
	if len(arr) == 1 and s[0] == kk:
		print(0)
	else:
		temp = 0
		for i in range(0, len(s)):
			if s[i] == kk:
				temp = 1
		tot = 0
		for i in range(0, len(s)):
			tot += s[i] - kk
		if tot == 0 or temp == 1:
			print(1)
		else:
			print(2)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def f():
	(n, x) = [int(s) for s in input().split()]
	A = [int(s) for s in input().split()]
	count = 0
	for a in A:
		if a == x:
			count += 1
	if count == n:
		print(0)
		return
	if x in A:
		print(1)
		return
	sum = 0
	for a in A:
		sum += a
	if sum == n * x:
		print(1)
		return
	print(2)
	return
for t in range(int(input())):
	f()


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	dic = defaultdict(lambda : 0)
	d = 0
	c = 0
	for i in range(n):
		d += l[i] == x
		c += l[i] - x
	if d == n:
		print(0)
	elif c == 0:
		print(1)
	elif c != 0 and d:
		print(1)
	else:
		print(2)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input().rstrip()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def ceil(a, b):
	return (a + b - 1) // b
file = 1

def f():
	sys.stdout.flush()

def solve():
	for _ in range(ii()):
		(n, x) = mi()
		a = li()
		if len(set(a)) == 1 and a[0] == x:
			print(0)
			continue
		s = 0
		for i in a:
			s += i - x
		if s == 0 or x in a:
			print(1)
		else:
			print(2)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

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

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

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

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for i in range(Int()):
		(m, k) = Mint()
		a = List()
		p = 0
		n = 0
		eq = 0
		for i in a:
			if i > k:
				p += i - k
			elif i < k:
				n += k - i
			else:
				eq += 1
		ans = 0
		if p != 0 or n != 0:
			if p == n:
				ans = 1
			elif eq > 0:
				ans = 1
			else:
				ans = 2
		print(ans)
solution()


t = int(input())
for q in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	z = 0
	flag = 0
	while a[z] == m:
		if z == n - 1:
			flag = 1
			break
		z += 1
	if flag == 1:
		print(0)
	elif flag == 0 and sum(a) / n == m:
		print(1)
	elif m in a:
		print(1)
	else:
		print(2)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = 1
t = int(input())
while t != 0:
	t -= 1
	no = 0
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	for item in a:
		if item == x:
			no += 1
	if no == n:
		print(0)
		continue
	tot = sum(a)
	if tot == n * x or no > 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if a.count(x) == n:
		print('0')
		continue
	sm = 0
	for i in a:
		sm += x - i
	if sm == 0 or x in a:
		print('1')
	else:
		print('2')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	print((0, 2 - (x in l or sum(l) == x * n))[l != [x] * n])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) == n * k:
		f = 0
		for i in l:
			if i != k:
				f = 1
		if f == 1:
			print(1)
		else:
			print(0)
	else:
		f = 0
		for i in l:
			if i == k:
				f = 1
		if f == 1:
			print(1)
		else:
			print(2)


t = int(input())
w = []
for i in range(t):
	(n, x) = input().split()
	x = int(x)
	n = int(n)
	r = list(map(int, input().split()))
	boo = True
	for i in r:
		if i != x:
			boo = False
			break
	if boo == True:
		w.append(0)
	else:
		ras = 0
		for i in r:
			ras = ras + x - i
		if ras == 0:
			w.append(1)
		else:
			cc = 0
			for i in r:
				if i == x:
					cc = cc + 1
			if cc >= 1:
				w.append(1)
			else:
				w.append(2)
for i in w:
	print(i)


t = int(input())
for _ in range(t):
	(n, x) = (int(w) for w in input().split(' '))
	A = [int(a) for a in input().split(' ')]
	if n * x == sum(A):
		if all((a == x for a in A)):
			print(0)
		else:
			print(1)
	elif any((a == x for a in A)):
		print(1)
	else:
		print(2)


for h in range(int(input())):
	(n, x) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	sumi = 0
	c = 0
	for i in arr:
		if i != x:
			sumi += i
			c += 1
	if c == 0:
		print(0)
	elif sumi / c == x or c < n:
		print(1)
	else:
		print(2)


t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	if a.count(x):
		if a.count(x) == n:
			print(0)
		else:
			print(1)
	else:
		b = list(set(a))
		s = 0
		for i in b:
			s += a.count(i) * (i - x)
		if s == 0:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	sm = sum(arr)
	if all((i == x for i in arr)):
		print(0)
		continue
	if sum(arr) == n * x:
		print(1)
		continue
	if x in arr:
		print(1)
		continue
	print(2)


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def solve():
	c = aa.count(x)
	if c == n:
		return 0
	if sum(aa) == x * n or c > 0:
		return 1
	return 2
for _ in range(II()):
	(n, x) = MI()
	aa = LI()
	print(solve())


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	v = list(map(int, input().split()))
	t = set(v)
	if t == {b}:
		print(0)
	else:
		ans = 0
		for i in v:
			ans += b - i
		if ans == 0 or b in t:
			print(1)
		else:
			print(2)


from math import pow
t = int(input())
for _ in range(t):
	inp = list(map(int, input().split()))
	(n, x) = (inp[0], inp[1])
	a = list(map(int, input().split()))
	s = sum(a)
	if s % n == 0 and s // n == x or x in a:
		for i in range(n):
			if a[i] != x:
				print(1)
				break
			if i == n - 1:
				print(0)
	else:
		print(2)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

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

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
mod = 998244353
INF = float('inf')
for t in range(int(data())):
	(n, x) = mdata()
	a = mdata()
	if max(a) == min(a) == x:
		out(0)
	elif x in a or sum(a) == n * x:
		out(1)
	else:
		out(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ls = list(map(int, input().split()))
	sm = 0
	cnt = 0
	for i in range(n):
		if ls[i] == x:
			cnt += 1
		else:
			sm += x - ls[i]
	if cnt == n:
		print(0)
	elif sm == 0 or cnt >= 1:
		print(1)
	else:
		print(2)


I = lambda : map(int, input().split())
(t,) = I()
exec('n,x=I();*s,=I();print([0,2-(x in s or sum(s)==x*n)][{*s}!={x}]);' * t)


test = int(input())
for t in range(0, test):
	(n, x) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	u = []
	for e in a:
		if e != x:
			u.append(e)
	if len(u) == 0:
		print(0)
		continue
	if len(u) != n:
		print(1)
		continue
	elif sum(a) == n * x:
		print(1)
		continue
	else:
		print(2)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter
cases = int(input())
for t in range(cases):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = [x - i for i in a]
	lb = sum(b)
	b = Counter(b)
	v = b.get(0, 0)
	if v:
		if v == n:
			print(0)
		else:
			print(1)
	elif lb == 0:
		print(1)
	else:
		print(2)


def solve(n, x, A):
	l_val = 0
	r_val = 0
	already = 0
	for i in range(n):
		if A[i] > x:
			r_val += A[i] - x
		elif A[i] == x:
			already += 1
		else:
			l_val += x - A[i]
	if r_val == 0 and l_val == 0:
		return 0
	elif already > 0 or l_val == r_val:
		return 1
	else:
		return 2
t = int(input())
while t:
	res = []
	(n, x) = map(int, input().split(' '))
	in_ = map(int, input().split(' '))
	for c in in_:
		res.append(int(c))
	print(solve(n, x, res))
	t -= 1


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(inverse(farr[-1], mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class DSU:

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

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

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

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

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

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d
t = N()
for i in range(t):
	(n, x) = RL()
	a = RLL()
	s = sum(a)
	if all((y == x for y in a)):
		ans = 0
	elif s == x * n or any((y == x for y in a)):
		ans = 1
	else:
		ans = 2
	print(ans)


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint

def main():
	(n, x) = map(int, input().split())
	arr = list(map(lambda it: int(it) - x, input().split()))
	if any(arr):
		if sum(arr) == 0 or 0 in arr:
			print(1)
		else:
			print(2)
	else:
		print(0)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	main()


from sys import stdin, stdout, setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, x) = iia()
	arr = iia()
	tot = 0
	temp = []
	for i in arr:
		tot += x - i
	if set(arr) == set([x]):
		print(0)
	elif tot == 0:
		print(1)
	elif tot != 0 and x in arr:
		print(1)
	else:
		print(2)


def solve(n, k):
	s = list(map(int, input().split()))
	cnt = 0
	for i in s:
		if i == k:
			cnt += 1
	if cnt == n:
		return 0
	if cnt > 0:
		return 1
	s = list(map(lambda x: x - k, s))
	if sum(s) == 0:
		return 1
	return 2
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	print(solve(n, k))
	t -= 1


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(n, x, a):
	num_equal_x = a.count(x)
	if num_equal_x == n:
		return 0
	elif num_equal_x > 0:
		return 1
	elif sum(a) == x * n:
		return 1
	return 2
t = int(input())
output = []
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	output.append(solve(n, x, a))
print(*output, sep='\n')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	ans = 2
	if sum(a) / n == k:
		ans = 1
	if k in a:
		ans = 1
	if len(set(a)) == 1:
		if a[0] == k:
			ans = 0
	print(ans)


t = int(input())
for tc in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	flag = 0
	summ = 0
	for i in range(n):
		if arr[i] == x:
			flag += 1
		summ += arr[i]
	if flag == n:
		print(0)
	elif flag > 0:
		print(1)
	elif summ == n * x:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline

def solve():
	(n, x) = map(int, input().split())
	L = list(map(int, input().split()))
	if sum(L) == n * x:
		if min(L) == x:
			print(0)
		else:
			print(1)
	elif any((v == x for v in L)):
		print(1)
	else:
		print(2)
for _ in range(int(input())):
	solve()


rw = int(input())
for wewq in range(rw):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	t = False
	for i in a:
		if i % 2 == 0:
			t = True
			break
	tt = 0
	for i in range(n):
		if a[i] == x:
			tt += 1
	ss = 0
	ssn = 0
	bs = 0
	bsn = 0
	for i in a:
		if i < x:
			ss += i
			ssn += 1
		elif i > x:
			bs += i
			bsn += 1
	if tt == n:
		print(0)
	elif x * ssn - ss == bs - x * bsn or tt != 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	v = list(map(int, input().split()))
	sum = 0
	zero = 1
	one = 0
	for i in v:
		if i != k:
			zero = 0
		else:
			one = 1
		sum += i - k
	if zero:
		print(0)
	elif one or not sum:
		print(1)
	else:
		print(2)


t = int(input())
for tt in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	if len(set(a)) == 1 and m in a:
		print(0)
	elif sum(a) == n * m or m in a:
		print(1)
	else:
		print(2)


import sys

def input():
	return sys.stdin.readline()[:-1]

def getInt():
	return int(input())

def getIntIter():
	return map(int, input().split())

def getIntList():
	return list(getIntIter())

def flush():
	sys.stdout.flush()
for _ in range(getInt()):
	(n, x) = getIntIter()
	nums = getIntList()
	if nums == [x] * n:
		print(0)
	elif sum(nums) % n == 0 and sum(nums) // n == x or x in nums:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(N, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	(count, sum_) = (0, 0)
	for i in range(N):
		count += arr[i] == x
		sum_ += arr[i]
	if count == N:
		print(0)
	elif count > 0 or sum_ == N * x:
		print(1)
	else:
		print(2)


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 2
	s = sum(a)
	if a.count(x) == n:
		ans = 0
	elif s == n * x or a.count(x) > 0:
		ans = 1
	print(ans)
t = int(input())
while t > 0:
	solve()
	t -= 1


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
from itertools import permutations as permu

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
for _ in range(num):
	(n, x) = zzz()
	arr = szzz()
	lst = []
	for i in arr:
		lst.append(i - x)
	if len(set(lst)) == 1 and list(set(lst))[0] == 0:
		print(0)
		continue
	if sum(lst) == 0:
		print(1)
		continue
	if x in arr:
		print(1)
		continue
	print(2)


import sys, math
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('out.txt', 'w'))
except:
	pass
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from statistics import mode
from collections import *
from math import ceil, floor, inf, factorial, gcd, log2, sqrt, log
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()

def lcm(a, b):
	return a * b // gcd(a, b)

def setbits(n):
	return bin(n).count('1')

def resetbits(n):
	return bin(n).count('0')

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r):
	(num, den) = (1, 1)
	r = min(n, n - r)
	for i in range(r):
		num *= n - i
		den *= i + 1
	return num // den

def ncr_p(n, r, p):
	(num, den) = (1, 1)
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modinv(den, p) % p

def isPrime(num):
	if num <= 1:
		return False
	if num == 2 or n == 3:
		return True
	if num % 2 == 0 or num % 3 == 0:
		return False
	m = int(num ** 0.5) + 1
	for i in range(5, m, 6):
		if num % i == 0 or num % (i + 2) == 0:
			return False
	return True

def bin_search(s, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if s[mid] == val:
			return mid
		elif s[mid] < val:
			low = mid + 1
		else:
			high = mid - 1
	return -1

def sumofdigit(num):
	count = 0
	while num:
		count += num % 10
		num //= 10
	return count

def inputmatrix():
	(r, c) = iia()
	mat = [0] * r
	for i in range(r):
		mat[i] = iia()
	return (r, c, mat)

def prefix_sum(n, s):
	for i in range(1, n):
		s[i] += s[i - 1]
	return s

def binomial(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
	return res
for _ in range(ii1()):
	(n, k) = iia()
	arr = iia()
	flag = True
	flag2 = False
	for i in arr:
		if i != k:
			flag = False
		if i == k:
			flag2 = True
	a = sum(arr)
	if flag:
		print(0)
	elif flag2 or a == k * n:
		print(1)
	else:
		print(2)


import sys
import math
input = sys.stdin.readline
t = int(input())
for x in range(t):
	(n, x) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))
	total = sum(A)
	unique = set(A)
	has_infected = x in A
	if len(unique) == 1 and A[0] == x:
		print(0)
	elif x * n == total or has_infected:
		print(1)
	else:
		print(2)


t = eval(input())
for i in range(t):
	pp = input()
	p = [int(x) for x in pp.split()]
	n = p[0]
	y = p[1]
	qq = input()
	q = [int(x) for x in qq.split()]
	if all((j == y for j in q)):
		print(0)
	else:
		s = 0
		for x in q:
			s += x
		if s == n * y or y in q:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	counter = 0
	s = 0
	li = [int(b) for b in input().split()]
	for k in li:
		if k == x:
			counter += 1
		s += k
	if counter == n:
		print(0)
	elif counter > 0 or s == n * x:
		print(1)
	else:
		print(2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if min(a) == max(a) == x:
		print(0)
		continue
	if x in a or sum(a) == n * x:
		print(1)
		continue
	print(2)


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	(n, x) = M()
	l = L()
	s = 0
	if max(l) == min(l) == x:
		print(0)
		continue
	for i in range(n):
		s += x - l[i]
	if s == 0 or x in l:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	ls = [int(a) for a in input().split()]
	ls.sort()
	x1 = ls.count(x)
	if x1 == n:
		print(0)
	elif x1 >= n / 2:
		print(1)
	elif x1 > 0:
		print(1)
	elif sum(ls) / len(ls) == x:
		print(1)
	else:
		print(2)


def Str_to_List(Str):
	List = Str.split(' ')
	for i in range(len(List)):
		List[i] = int(List[i])
	return List

def Min_turns(List):
	Sum = 0
	All = True
	Infected = False
	x = List[0]
	for i in range(len(List)):
		if List[i] != x:
			All = False
	for i in range(1, len(List)):
		if List[i] == x:
			Infected = True
	for i in range(1, len(List)):
		Sum += x - List[i]
	if All == True:
		return 0
	elif Sum == 0 or Infected == True:
		return 1
	else:
		return 2
trials = int(input(''))
for i in range(trials):
	List1 = Str_to_List(input(''))
	List2 = Str_to_List(input(''))
	List = [List1[1]]
	for i in range(len(List2)):
		List.append(List2[i])
	print(Min_turns(List))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	sum_a = sum(a)
	cnt = 0
	for i in range(n):
		if x == a[i]:
			cnt += 1
	if cnt == n:
		print(0)
		continue
	if sum_a == n * x:
		print(1)
		continue
	if cnt >= 1:
		print(1)
		continue
	print(2)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	s = set(arr)
	if len(s) == 1 and arr[0] == x:
		print(0)
		continue
	flag = False
	s = 0
	for i in arr:
		s = s + (i - x)
		if i == x:
			flag = True
			break
	if flag or s == 0:
		print(1)
		continue
	print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	sm = 0
	for i in a:
		sm += x - i
	if sm == 0:
		if len(set(a)) == 1:
			print(0)
		else:
			print(1)
	elif x in a:
		print(1)
	else:
		print(2)


q = int(input())
for _ in range(q):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	g = l.count(x)
	dup = sum(l)
	if g == 0:
		if dup == x * n:
			print(1)
		else:
			print(2)
	elif l == [x] * n:
		print(0)
	else:
		print(1)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	v = [x - int(i) for i in input().split()]
	v.sort()
	if set(v) == {0}:
		print(0)
	elif sum(v) == 0 or 0 in v:
		print(1)
	else:
		print(2)


from collections import *
for T in range(int(input())):
	(n, x) = map(int, input().split())
	p = sorted(map(int, input().split()))
	lo = sum([x - k for k in p if k < x])
	hi = sum([k - x for k in p if k > x])
	eq = len([k for k in p if k == x])
	if p[1:] == p[:-1] and (not lo) and (not hi):
		print(0)
	elif lo == hi:
		print(1)
	elif eq > 0:
		print(1)
	else:
		print(2)


import math
t = int(input())
while t:
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	s = 0
	flag = False
	eq = False
	for i in range(n):
		s += x - a[i]
		flag |= x != a[i]
		eq |= x == a[i]
	if s == 0:
		if flag:
			print(1)
		else:
			print(0)
	elif eq:
		print(1)
	else:
		print(2)
	t -= 1


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	if a.count(x) == 0:
		less = 0
		more = 0
		for i in a:
			if i < x:
				less += x - i
			else:
				more += i - x
		if more == less:
			print(1)
		else:
			print(2)
	elif a.count(x) == len(a):
		print(0)
	else:
		print(1)


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	t = int(input())
	ans_a = [''] * t
	for ti in range(t):
		(n, x) = map(int, input().split())
		a = sorted(map(int, input().split()))
		if a[0] == a[-1] == x:
			ans_a[ti] = '0'
		elif sum(a) == x * n or x in a:
			ans_a[ti] = '1'
		else:
			ans_a[ti] = '2'
	output(*ans_a)
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = [int(x) for x in input().split()]
	small = 0
	big = 0
	for i in l:
		if i < x:
			small += abs(i - x)
		elif i > x:
			big += abs(i - x)
	if len(set(l)) == 1 and l[0] == x:
		print(0)
	elif small == big or x in l:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	A = [int(x) for x in input().split()]
	ninf = sum((1 for a in A if a == x))
	if ninf == n:
		print(0)
		continue
	if ninf >= 1:
		print(1)
		continue
	if sum(A) == n * x:
		print(1)
		continue
	print(2)


import sys
import collections as cc
import bisect as bi
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, k) = I()
	l = I()
	if l.count(k) == n:
		print(0)
		continue
	else:
		s = 0
		for i in range(n):
			s += l[i] - k
		if s == 0 or k in l:
			print(1)
		else:
			print(2)


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq
import re

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		(n, x) = ain()
		l = ain()
		cc = 0
		for i in l:
			if i == x:
				cc += 1
		if cc == n:
			print(0)
		elif cc != 0:
			print(1)
		elif sum(l) / n == x:
			print(1)
		else:
			print(2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math, sys
from collections import defaultdict, Counter, deque
from functools import reduce
INF = float('inf')
MOD = int(1000000000.0) + 7

def solve():
	(n, x) = vars()
	ratings = array()
	total_diff = 0
	infected = 0
	for rating in ratings:
		if rating == x:
			infected += 1
		total_diff += rating - x
	if not total_diff and infected == n:
		print(0)
	elif not total_diff or (total_diff and infected):
		print(1)
	else:
		print(2)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(str(sep))
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)

def vars():
	return map(int, input().split())

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


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	sa = sum(a)
	(ma, mi) = (max(a), min(a))
	yes = x in a
	if ma == mi == x:
		print(0)
	elif yes:
		print(1)
	elif sa == x * n:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	sub = 0
	add = 0
	aux = 0
	for i in range(n):
		if arr[i] < k:
			add += k - arr[i]
		elif arr[i] > k:
			sub += arr[i] - k
		else:
			aux += 1
	if add == 0 and sub == 0:
		print(0)
	elif add == sub or aux >= 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if len(set(l)) == 1 and l[0] == k:
		print(0)
	else:
		p = 0
		for i in range(n):
			p += k - l[i]
		if p == 0 or k in l:
			print(1)
		else:
			print(2)


for ii in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	s = sum([x - i for i in a if i <= x])
	d = sum([i - x for i in a if i > x])
	if a.count(x) == n:
		print(0)
	elif s == d:
		print(1)
	elif n == 1 or x in a:
		print(1)
	else:
		print(2)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s1 = 0
	s2 = 0
	for i in a:
		if i < x:
			s1 += x - i
		elif i > x:
			s2 += i - x
	m = a.count(x)
	if m == n:
		print(0)
	elif s1 == s2 or m:
		print(1)
	else:
		print(2)


def solve():
	(n, x) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	s = 0
	found_1 = 0
	for i in a:
		if i == x:
			found_1 += 1
		s += i
	if found_1 == n:
		print(0)
	elif found_1 > 0 or s == x * n:
		print(1)
	else:
		print(2)
t = int(input().strip())
for _ in range(t):
	solve()


def floornum():
	t = int(input())
	for i in range(t):
		(n, x) = [int(x) for x in input().split()]
		a = [int(item) for item in input().split()]
		sum = 0
		k = 0
		for j in a:
			sum += j
			if j != x:
				k = 1
		if k == 0:
			print('0', end='\n')
		elif sum / n == x or x in a:
			print('1', end='\n')
		else:
			print('2', end='\n')
floornum()


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	cur = 0
	for i in range(n):
		if a[i] == x:
			cur += 1
	if cur == n:
		print(0)
	else:
		c = 0
		for i in range(n):
			if a[i] >= x:
				c += -(a[i] - x)
			else:
				c += x - a[i]
		if c == 0 or cur != 0:
			print(1)
		else:
			print(2)


def killJoy(x, n, ratings):
	initialInfection = 0
	for rating in ratings:
		if rating == x:
			initialInfection += 1
	if initialInfection == n:
		return 0
	if initialInfection >= 1:
		return 1
	summ = sum(ratings)
	if summ == x * n:
		return 1
	return 2
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ratings = list(map(int, input().split()))
	print(killJoy(x, n, ratings))


for w in range(int(input())):
	(n, x) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	b = []
	count = 0
	for i in range(n):
		b.append(a[i] - x)
		if a[i] == x:
			count += 1
	if count == n:
		print(0)
	elif count >= 1 or sum(b) == 0:
		print(1)
	else:
		print(2)


for j in range(int(input())):
	(n, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	cnt = 0
	s = 0
	for i in l:
		if i == x:
			cnt += 1
		s += i - x
	if cnt == n:
		print(0)
	elif cnt > 0:
		print(1)
	elif s == 0:
		print(1)
	else:
		print(2)


import sys
import os.path
from collections import *
import math
import bisect
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(n, x) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	cnt = arr.count(x)
	if cnt == n:
		print(0)
	elif sum(arr) == n * x:
		print(1)
	elif cnt >= 1:
		print(1)
	else:
		print(2)


def solve():
	(n, x) = map(int, input().split())
	p = list(map(int, input().split()))
	ok = True if x in p else False
	if p == [x] * n:
		print(0)
	elif ok:
		print(1)
	else:
		k = 0
		for i in p[:n - 1]:
			k += i - x
		p[-1] += k
		if p[-1] == x:
			print(1)
		else:
			print(2)
	return

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


import sys

def inp():
	return sys.stdin.readline().rstrip('\n').encode('utf8')

def mpint():
	return map(int, sys.stdin.readline().split(' '))

def itg():
	return int(sys.stdin.readline())
for __ in range(itg()):
	(n, x) = mpint()
	arr = tuple(mpint())
	c = arr.count(x)
	s = sum(arr)
	if c == n:
		print(0)
	elif c or s == x == 0 or s / n == x:
		print(1)
	else:
		print(2)


import sys, os, io
I = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for tc in range(1, 1 + int(I())):
	(n, x) = map(int, I().split())
	a = list(map(int, I().split()))
	sm = sum(a)
	if max(a) == min(a) == x:
		print(0)
	elif sm % n == 0 and sm // n == x or x in a:
		print(1)
	else:
		print(2)


def kill(arr, n, m):
	flag = 1
	for i in range(n):
		if arr[i] != m:
			flag = 0
			break
	if flag == 1:
		return 0
	f2 = 0
	for i in range(n):
		if arr[i] == m:
			f2 = 1
			break
	if f2 == 1:
		return 1
	f3 = 0
	res = 0
	for i in range(n):
		res += arr[i] - m
	if res == 0:
		return 1
	return 2
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(kill(arr, n, m))


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	x = sum(a)
	if a.count(k) == n:
		print(0)
	elif a.count(k) < n and a.count(k) > 0:
		print(1)
	elif x - k * n == 0:
		print(1)
	else:
		print(2)


import os, sys
from io import BytesIO, IOBase
from bisect import bisect_right

def main():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		su = sum(a)
		ini = a.count(x)
		if ini == n:
			print(0)
		elif not ini:
			if su == n * x:
				print(1)
			else:
				print(2)
		else:
			print(1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	ct = arr.count(x)
	if ct == n:
		print(0)
	elif ct >= 1:
		print(1)
	else:
		s = sum(arr)
		if s % n == 0 and s // n == x:
			print(1)
		else:
			print(2)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, x) = LI()
		a = LI()
		t = 0
		u = 0
		o = 0
		for c in a:
			if c > x:
				t += c - x
			elif c < x:
				u += x - c
			else:
				o = 1
		rr.append(IF(t == 0 and u == 0, 0, IF(t == u or o, 1, 2)))
	return JA(rr, '\n')
print(main())


def get_int():
	return int(input())

def get_ints():
	return [int(x) for x in input().split()]
for t in range(0, get_int()):
	(n, y) = get_ints()
	accounts = get_ints()
	s = sum(accounts)
	if y in accounts and len(set(accounts)) == 1:
		print(0)
		continue
	if y in accounts or n * y == s:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	[n, x] = input().split()
	n = int(n)
	x = int(x)
	a = input().split()
	a = [int(k) for k in a]
	if all((k == x for k in a)):
		print(0)
	elif any((k == x for k in a)):
		print(1)
	elif sum(a) == n * x:
		print(1)
	else:
		print(2)


def counter(n, x, ratings):
	if set(ratings) == {x}:
		return 0
	count = ratings.count(x)
	total = sum(ratings)
	if count == 0:
		if total - n * x == 0:
			return 1
	else:
		return 1
	return 2
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ratings = list(map(int, input().split()))
	print(counter(n, x, ratings))
pass


t = int(input())
while t:
	t -= 1
	(n, x) = list(map(int, input().split()))
	s = list(map(int, input().split()))
	suma = 0
	c = 1
	c2 = 0
	for i in s:
		suma += i
		if i != x:
			c = 0
		if i == x:
			c2 = 1
	if c:
		print(0)
	elif suma / n == x or c2:
		print(1)
	else:
		print(2)


def main():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		case_0 = True
		for i in a:
			if i != x:
				case_0 = False
				break
		if case_0:
			print(0)
			continue
		case_1_base = False
		for j in a:
			if j == x:
				case_1_base = True
				break
		if case_1_base:
			print(1)
			continue
		total_diff = 0
		for k in a:
			total_diff += k - x
		if total_diff == 0:
			print(1)
		else:
			print(2)
main()


for i in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	s = list(map(int, input().split()))
	if len(set(s)) == 1 and s[0] == x:
		print(0)
	elif sum(s) == n * x or x in s:
		print(1)
	else:
		print(2)


def main():
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	if all((i == x for i in lst)):
		print(0)
	elif lst.count(x) != 0:
		print(1)
	elif sum(lst) == n * x:
		print(1)
	else:
		print(2)
from math import *
input = __import__('sys').stdin.readline
for test in range(int(input())):
	main()


for t in range(int(input())):
	(n, x) = map(int, input().split())
	x += 4000
	a = []
	for v in list(map(int, input().split())):
		b = v + 4000
		if b != x:
			a.append(b)
	s = sum(a)
	if len(a) == 0:
		print(0)
	elif len(a) != n or (s % len(a) == 0 and s // len(a) == x):
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
t = int(input())
for ii in range(t):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	B = []
	c = A.count(x)
	for i in range(n):
		if A[i] != x:
			B.append(A[i])
	if B == []:
		print(0)
	elif c > 0 or sum(B) == x * len(B):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = [int(c) for c in input().split()]
	arr = [int(c) for c in input().split()]
	ans = [x - i for i in arr]
	if ans.count(0) == len(ans):
		print(0)
	elif sum(ans) == 0:
		print(1)
	elif arr.count(x) >= 1:
		print(1)
	else:
		print(2)


t = int(input())
q = []
for i in range(t):
	l = list(input().split())
	n = int(l[0])
	x = int(l[1])
	m = list(map(int, list(input().split())))
	if m.count(x) == n:
		q.append(0)
	elif sum(m) == x * n or m.count(x) > 0:
		q.append(1)
	else:
		q.append(2)
for i in q:
	print(i)


def main():
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	(zero, one) = (True, False)
	diff = 0
	for i in range(n):
		diff += arr[i] - x
		if arr[i] == x:
			one = True
		else:
			zero = False
	if zero:
		print('0')
	elif one or diff == 0:
		print('1')
	else:
		print('2')
for _ in range(int(input())):
	main()


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if a.count(k) == n:
		print(0)
	elif a.count(k) >= 1:
		print(1)
	else:
		ss = sum(a)
		if ss - n * k == 0:
			print(1)
		else:
			print(2)


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(n, x) = [int(x) for x in input().split()]
		ratings = [int(x) for x in input().split()]
		if len(set(ratings)) == 1 and ratings[0] == x:
			print(0)
			continue
		if x in ratings:
			print(1)
			continue
		for i in range(n):
			ratings[i] = ratings[i] - x
		if sum(ratings) == 0:
			print(1)
			continue
		print(2)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	if a[0] == x and a[-1] == x:
		print(0)
	elif a.count(x) >= 1:
		print(1)
	elif sum(a) / n == x and n % 2 == 0:
		print(1)
	else:
		print(2)


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	(n, x) = idata()
	data = idata()
	flag = 0
	summ = 0
	for i in range(n):
		summ += data[i]
		if data[i] == x:
			flag += 1
	if flag == n:
		print(0)
		return
	if flag:
		print(1)
		return
	if summ // n == x and summ % n == 0:
		print(1)
		return
	print(2)
	return
for t in range(int(ii())):
	solve()


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	(n, x) = ilele()
	A = alele()
	if len(set(A)) == 1 and A[0] == x:
		print(0)
		continue
	dif = sum([i - x for i in A])
	if dif == 0 or x in A:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
	(N, M) = map(int, input().split())
	X = list(map(int, input().split()))
	if len(set(X)) == 1 and M == X[0]:
		print(0)
		continue
	t = 0
	for x in X:
		t += M - x
	if t == 0:
		print(1)
		continue
	if M in X:
		print(1)
		continue
	print(2)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = inar()
		arr = inar()
		sm = 0
		count = 0
		for i in range(n):
			sm += x - arr[i]
			if arr[i] == x:
				count += 1
				continue
		if count == n:
			print(0)
		elif sm == 0 or x in arr:
			print(1)
		else:
			print(2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	k = [z == x for z in l]
	if all(k):
		print(0)
	elif sum(l) == n * x or any(k):
		print(1)
	else:
		print(2)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sum(a)
	eq = all([i == k for i in a])
	if eq:
		print(0)
	elif s == k * n or k in a:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	if set(arr) == {x}:
		print(0)
		continue
	s = sum(arr)
	if s // n * n == s and s // n == x or x in arr:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	rate_change = 0
	(n, x) = map(int, input().split())
	acc = list(map(int, input().split()))
	acc1 = []
	for i in acc:
		if i != x:
			acc1.append(i)
	if not acc1:
		print(0)
		continue
	if len(acc1) < n:
		print(1)
		continue
	for i in acc1:
		rate_change += i - x
	if rate_change == 0:
		print(1)
	else:
		print(2)


import math
t = int(input())
for _ in range(t):
	(n, infected) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	diff = 0
	c = 0
	for i in range(n):
		diff += infected - arr[i]
		if arr[i] == infected:
			c += 1
	if diff == 0:
		if c == n:
			print(0)
		else:
			print(1)
	elif c >= 1:
		print(1)
	else:
		print(2)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	(n, x) = I()
	l = list(I())
	a = 0
	for i in l:
		a += i - x
	if set(l) == {x}:
		print(0)
	elif x in l or a == 0:
		print(1)
	else:
		print(2)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	isAllX = True
	isOneX = False
	for elem in a:
		if elem != x:
			isAllX = False
		if elem == x:
			isOneX = True
	if isAllX:
		print(0)
	elif sum(a) == n * x or isOneX:
		print(1)
	else:
		print(2)


import sys, os, io
input = sys.stdin.readline
T = int(input())
ans = [0] * T
for t in range(T):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	if len(set(A + [x])) == 1:
		continue
	if sum(A) == x * n:
		ans[t] = 1
		continue
	if x in A:
		ans[t] = 1
		continue
	ans[t] = 2
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))

	def soln():
		setArr = set(arr)
		if len(setArr) == 1 and arr[0] == x:
			return 0
		avg = sum(arr) / n
		if avg == x or x in setArr:
			return 1
		return 2
	result = soln()
	print(result)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 30, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	se = set(l)
	if n == 1:
		if l[0] == k:
			print(0)
		else:
			print(1)
	if l[0] == l[-1] == k:
		print(0)
	elif sum(l) == n * k:
		print(1)
	elif k in se:
		print(1)
	else:
		print(2)


t = int(input())
while t:
	t += -1
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if len(set(l)) == 1 and l[0] == x:
		print(0)
	elif sum(l) / n == x:
		print(1)
	else:
		ch = 0
		for i in l:
			if i == x:
				ch = 1
				break
		if ch:
			print(1)
		else:
			print(2)


def MI():
	return map(int, input().split())
for _ in range(int(input())):
	(n, x) = MI()
	arr = list(MI())
	c = arr.count(x)
	s = sum(arr)
	if c == n:
		print(0)
	elif s % n == 0 and s // n == x:
		print(1)
	elif c > 0:
		print(1)
	else:
		print(2)


o = int(input())
for i in range(0, o):
	p = list(map(int, input().split()))
	n = list(map(int, input().split()))
	h = []
	y = 0
	for j in range(0, p[0]):
		h.append(n[j] - p[1])
	for j in range(0, len(h)):
		if h[j] != 0:
			y = 1
	if y == 1 and 0 in h:
		y = 2
	if sum(h) == 0 and y == 0:
		print(0)
	elif sum(h) == 0 and y == 1 or y == 2:
		print(1)
	else:
		print(2)


from collections import Counter
from collections import OrderedDict
from collections import defaultdict

def SOCountR(mylist):
	return OrderedDict(sorted(Counter(mylist).items(), reverse=True))

def SOCount(mylist):
	return OrderedDict(sorted(Counter(mylist).items()))

def freq_count(mylist):
	return Counter(mylist)
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	diff = []
	s = 0
	cnt = 0
	for i in range(n):
		diff.append(arr[i] - x)
		if diff[i] == 0:
			cnt += 1
		s += diff[i]
	if s == 0:
		if cnt == n:
			print('0')
		else:
			print('1')
	elif cnt == 0:
		print(2)
	else:
		print('1')


t = int(input())
for _ in range(t):
	(n, x) = [int(p) for p in input().split()]
	arr = [int(p) for p in input().split()]
	sm = 0
	for i in range(len(arr)):
		sm += x - arr[i]
	if arr.count(x) == n:
		print(0)
	elif sm == 0 or x in arr:
		print(1)
	else:
		print(2)


def ans(a, n, k):
	same = 0
	for i in a:
		if i == k:
			same += 1
	if same == n:
		return 0
	if sum(a) % n == 0 and sum(a) // n == k:
		return 1
	if same > 0:
		return 1
	return 2
m = int(input())
for i in range(m):
	brr = input().split()
	n = int(brr[0])
	k = int(brr[1])
	arr = input().split()
	a = []
	for i in arr:
		a.append(int(i))
	print(ans(a, n, k))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	if x in a:
		if max(a) == min(a):
			print(0)
		else:
			print(1)
	elif sum(a) / n == x:
		print(1)
	else:
		print(2)


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	(n, x) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	diff_arr = [0 for i in range(n)]
	count_zero = 0
	for j in range(n):
		diff_arr[j] = x - arr[j]
		if diff_arr[j] == 0:
			count_zero += 1
	if count_zero == n:
		print(0)
	elif sum(diff_arr) == 0 or count_zero >= 1:
		print(1)
	else:
		print(2)


from collections import defaultdict

def main():
	for _ in range(int(input())):
		(n, x) = list(map(int, input().split()))
		d = defaultdict(int)
		l = list(map(int, input().split()))
		if l.count(x) == n:
			print(0)
		elif sum(l) == x * n or l.count(x) > 0:
			print(1)
		else:
			print(2)

def SumOfExpOfFactors(a):
	fac = 0
	lis = SortedList()
	if not a & 1:
		lis.add(2)
	while not a & 1:
		a >>= 1
		fac += 1
	for i in range(3, int(a ** 0.5) + 1, 2):
		if not a % i:
			lis.add(i)
		while not a % i:
			a //= i
			fac += 1
	if a != 1:
		lis.add(a)
		fac += 1
	return (fac, lis)
div = [0] * 1000001

def NumOfDivisors(n):
	for i in range(1, n + 1):
		for j in range(i, n + 1, i):
			div[j] += 1

def primes1(n):
	sieve = [True] * (n // 2)
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i // 2]:
			sieve[i * i // 2::i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [2 * i + 1 for i in range(1, n // 2) if sieve[i]]

def GCD(a, b):
	if b == 0:
		return a
	else:
		return GCD(b, a % b)

class Graph:

	def __init__(self):
		self.Graph = defaultdict(list)

	def addEdge(self, u, v):
		self.Graph[u].append(v)
		self.Graph[v].append(u)

	def DFSUtil(self, v, visited):
		visited.add(v)
		for neighbour in self.Graph[v]:
			if neighbour not in visited:
				self.DFSUtil(neighbour, visited)

	def DFS(self, v):
		visited = set()
		self.DFSUtil(v, visited)

	def BFS(self, s):
		visited = set()
		queue = []
		queue.append(s)
		visited.add(s)
		while queue:
			s = queue.pop(0)
			for i in self.Graph[s]:
				if i not in visited:
					queue.append(i)
					visited.add(i)

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))
main()


for _ in range(int(input())):
	(n, x) = tuple(map(int, input().split()))
	arr = list(map(int, input().split()))
	if all((i == x for i in arr)):
		print(0)
	elif sum((i - x for i in arr)) == 0 or any((i == x for i in arr)):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	ls = [0] * n
	a = 0
	b = 0
	for i in range(n):
		var = x - arr[i]
		ls[i] = var
		if var < 0:
			a += var
		else:
			b += var
	if a == 0 and b == 0:
		print(0)
	elif a + b == 0:
		print(1)
	elif x in arr:
		print(1)
	else:
		print(2)


from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	left = 0
	right = 0
	neutral = 0
	for i in a:
		if i > x:
			right += i - x
		elif i < x:
			left += x - i
		else:
			neutral += 1
	if neutral == n:
		print(0)
	elif left == right or neutral:
		print(1)
	elif left or right:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split(' ')))
	ratings = list(map(int, input().split(' ')))
	f = 0
	for i in ratings:
		if i != x:
			f = 1
	if f == 0:
		print(0)
		continue
	diff = 0
	same_rating = False
	for i in ratings:
		diff += x - i
		if i == x:
			same_rating = True
	if diff == 0 or same_rating:
		print(1)
		continue
	else:
		print(2)


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
inp = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().rstrip('\n\r')
_T_ = inin()
for _t_ in range(_T_):
	(n, x) = inar()
	a = inar()
	if set(a) == {x}:
		print(0)
	elif sum(a) / n == x:
		print(1)
	elif a.count(x) > 0:
		print(1)
	else:
		print(2)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
from types import GeneratorType
mod = pow(10, 9) + 7

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

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, x) = sp()
	arr = l()
	s = 0
	for i in arr:
		s += i - x
	if s == 0:
		if len(set(arr)) == 1:
			out(0)
		else:
			out(1)
		continue
	if x in arr:
		out(1)
		continue
	out(2)


from math import *
from cmath import *
from decimal import *
from fractions import *
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	(dem, s) = (0, 0)
	for _ in a:
		if _ == x:
			dem += 1
		s += _ - x
	if dem == n:
		print(0)
	elif dem >= 1 or s == 0:
		print(1)
	else:
		print(2)


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	(n, x) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	cnt = 0
	for i in range(n):
		if a[i] == x:
			cnt += 1
	if cnt == n:
		print(0)
		continue
	sa = sum(a)
	if sa == x * n or cnt > 0:
		print(1)
		continue
	print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	lo = 0
	up = 0
	for i in lis:
		if i < x:
			lo += x - i
		elif i > x:
			up += i - x
	if lo == 0 and up == 0:
		print(0)
	elif lo == up and lo > 0 or x in lis:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	diff_num = False
	has_same = False
	r = []
	for n in nums:
		if n != x:
			diff_num = True
		if n == x:
			has_same = True
		r.append(x - n)
	if diff_num == False:
		print(0)
	elif sum(r) == 0:
		print(1)
	elif has_same:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	(flag1, flag2) = (False, False)

	def count(n, x, l):
		l.sort()
		if l.count(x) == n:
			return 0
		elif l.count(x) > 0:
			return 1
		elif sum(l) % n == 0 and sum(l) // n == x:
			return 1
		else:
			return 2
	print(count(n, x, l))


for i in range(int(input())):
	(a, x) = [int(i) for i in input().split()]
	s = [int(i) for i in input().split()]
	print({0: {0: '2', 1: '1'}, 1: {0: '0', 1: '0'}}[s == [x for i in range(a)]][x in s or sum(s) == x * a])


def checkinfection(array, x):
	s = sum(array)
	flag = 0
	flag2 = 0
	for element in array:
		if element != x:
			flag = 1
		if element == x:
			flag2 = 1
	if flag == 0:
		return 0
	elif flag2 == 1:
		return 1
	elif sum(array) == x * len(array):
		return 1
	else:
		return 2
T = int(input())
for t in range(T):
	nx = input().split()
	x = int(nx[1])
	given = list(map(int, input().split()))
	print(checkinfection(given, x))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	s = sorted(map(int, input().split()))
	if len(set(s)) == 1 and s[0] == x:
		print(0)
	elif s.count(x) or sum(s) == x * n:
		print(1)
	else:
		print(2)


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	zero = True
	same = False
	sum = 0
	for i in a:
		if i != x:
			zero = False
		else:
			same = True
		sum += i
	if zero:
		print(0)
	elif same or sum == x * n:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = [0] * n
	t = 0
	for (i, j) in enumerate(a):
		if j == x:
			t += 1
			continue
		c[i] = j - x
	if t == n:
		print(0)
	elif sum(c) == 0 or t > 0:
		print(1)
	else:
		print(2)


t = int(input())
for z in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	sum_l = sum(l)
	count_e = l.count(x)
	if count_e == n:
		print('0')
	elif count_e > 0:
		print('1')
	elif sum_l == n * x:
		print('1')
	else:
		print('2')


import sys
import math
from math import inf, gcd
from functools import *
from itertools import *
from collections import *
from typing import *
sys.setrecursionlimit(10 ** 7)
t = int(input())
for i in range(t):
	(n, x) = (int(s) for s in input().split())
	a = [int(s) for s in input().split()]
	if all((j == x for j in a)):
		print(0)
	elif sum((j - x for j in a)) == 0 or any((j == x for j in a)):
		print(1)
	else:
		print(2)


from collections import defaultdict as dd
from sys import stdin, stdout
from bisect import bisect_left
from math import log, sqrt
for t in range(int(stdin.readline().strip())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	avg = sum(a) / n
	s = set(a)
	if len(s) == 1 and x == a[0]:
		print(0)
	elif avg == x or x in a:
		print(1)
	else:
		print(2)


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	f = 0
	for i in range(n):
		if a[i] != k:
			f = 1
			break
	if f == 0:
		print(0)
	else:
		x = []
		f = 0
		for i in range(n):
			if a[i] == k:
				f = 1
			x.append(a[i] - k)
		if sum(x) == 0 or f == 1:
			print(1)
		else:
			print(2)


def solve(n, x, ar):
	flag = False
	for i in range(n):
		if ar[i] == x:
			continue
		else:
			flag = True
			break
	if flag == False:
		print(0)
	else:
		found = False
		sumi = 0
		for i in range(n):
			if ar[i] == x:
				found = True
			sumi += ar[i] - x
		if sumi == 0 or found is True:
			print(1)
		else:
			print(2)
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ar = list(map(int, input().split()))
	solve(n, x, ar)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	f0 = not max(a) == min(a) == x
	print(f0 * ((x not in a and sum(a) != x * n) + 1))


t = int(input(''))
bal = []
arr = []
for i in range(t):
	bal.append(list(map(int, input().split())))
	arr.append(list(map(int, input().split())))
for i in range(t):
	b = bal[i]
	a = arr[i]
	a.sort()
	n = b[0]
	x = b[1]
	dp = a.copy()
	for j in range(n):
		dp[j] = dp[j] - x
	if a.count(x) == n:
		print(0)
		continue
	if sum(dp) == 0:
		print(1)
		continue
	s = sum(a)
	if s % n == 0 and s / n == x:
		print(1)
		continue
	cnt = a.count(x)
	if cnt:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(n, x) = [int(k) for k in input().split()]
	flag1 = True
	flag2 = False
	rating = [int(k) for k in input().split()]
	s = 0
	for k in range(n):
		if rating[k] == x:
			flag2 = True
		else:
			flag1 = False
		s += rating[k]
	if flag1:
		print(0)
	elif flag2 or s == x * n:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	c = A.count(x)
	if c == n:
		print(0)
	else:
		s = sum(A)
		if s // n == s / n and s // n == x:
			print(1)
		elif x in A:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	(num, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = set(l)
	if s == set([x]):
		print(0)
	elif x in s or sum(l) == num * x:
		print(1)
	else:
		print(2)


t = int(input())
for q in range(t):
	(n, x) = map(int, input().split())
	mass = list()
	flag = False
	for i in input().split():
		y = int(i)
		if y == x:
			n -= 1
		else:
			mass.append(y)
		if y == x:
			flag = True
	if n == 0:
		print(0)
	elif sum(mass) / n == x or flag:
		print(1)
	else:
		print(2)


import sys

def main():
	t = Iint()
	for _ in range(t):
		(n, rating_of_killjoy) = Imap()
		a = Ilist()
		count_a = a.count(rating_of_killjoy)
		set_a = set(a)
		sum_a = sum(a)
		if set_a == set({rating_of_killjoy}):
			print(0)
		elif sum_a == n * rating_of_killjoy:
			print(1)
		elif rating_of_killjoy in set_a:
			print(1)
		else:
			print(2)
en = enumerate
FIO = 10

def debug(*args, c=6):
	pass
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=sys.stderr)
BUFSIZE = 8 * 1024

def Istr():
	return input()

def Iint():
	return int(input())

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

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import os

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for case in range(t):
	(n, r) = map(int, input().split())
	arr = list(map(int, input().split()))
	f = True
	for x in arr:
		if x != r:
			f = False
			break
	if f:
		print(0)
		continue
	if sum([arr[x] - r for x in range(n)]) == 0 or arr.count(r) >= 1:
		print(1)
		continue
	print(2)


import collections

def solution(n, x, a):
	if a == [x] * n:
		return 0
	elif sum(a) == x * n:
		return 1
	elif x in a:
		return 1
	else:
		return 2
t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	print(solution(n, x, a))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for j in range(int(input())):
	(n, x) = map(int, input().split())
	vals = list(map(int, input().split()))
	equal = 0
	pos = 0
	neg = 0
	for s in range(n):
		if vals[s] == x:
			equal += 1
		elif x - vals[s] > 0:
			pos += x - vals[s]
		else:
			neg += vals[s] - x
	if equal == n:
		print(0)
	elif pos == neg:
		print(1)
	elif equal > 0:
		print(1)
	else:
		print(2)


N = int(input())
Ans = []
for i in range(N):
	(M, R) = map(int, input().split())
	A = list(map(int, input().split()))
	p = 0
	q = 0
	total = 0
	for j in range(M):
		if A[j] != R:
			p = 1
	for j in range(M):
		if A[j] == R:
			q = 1
		total += A[j] - R
	if p == 0:
		Ans.append(0)
	elif total == 0 or q == 1:
		Ans.append(1)
	else:
		Ans.append(2)
for i in Ans:
	print(i)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	if max(A) == min(A) == x:
		print(0)
	else:
		count = 0
		for a in A:
			if a == x:
				count += 1
		B = [a - x for a in A]
		if sum(B) == 0:
			print(1)
			continue
		if count >= 1:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = a[0]
	same = x == a[0]
	was = same
	for i in range(1, len(a)):
		s += a[i]
		same = same and a[i] == a[i - 1]
		was = was or a[i] == x
	if same:
		print(0)
	elif s % n == 0 and s // n == x or was:
		print(1)
	else:
		print(2)


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

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

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('0') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, x) = inputnums()
	a = inputlist()
	good = 0
	sm = 0
	for i in range(n):
		sm += a[i]
		if a[i] == x:
			good += 1
	if good == n:
		print(0)
	elif good > 0 or sm == x * n:
		print(1)
	else:
		print(2)


import sys

def I():
	return int(sys.stdin.readline().rstrip())

def MI():
	return map(int, sys.stdin.readline().rstrip().split())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))
t = I()
for _ in range(t):
	(n, x) = MI()
	A = LI()
	b = sum((A[i] == x for i in range(n)))
	if b == n:
		print(0)
		continue
	if sum(A) == n * x:
		print(1)
		continue
	if b >= 1:
		print(1)
		continue
	print(2)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)

def solve():
	(n, avg) = map(int, input().split())
	arr = list(map(int, input().split()))
	sn = cnt = 0
	for c in arr:
		if c != avg:
			sn += c
			cnt += 1
	if cnt == 0:
		return 0
	if cnt != n:
		return 1
	if avg * cnt == sn:
		return 1
	return 2
t = int(input())
for _ in range(t):
	print(solve())


import math
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	s = list(set(a))
	if len(s) == 1 and s[0] == x:
		print(0)
	else:
		b = []
		f = 0
		for i in range(n):
			b.append(x - a[i])
			if a[i] == x:
				f = 1
		if sum(b) == 0 or f == 1:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:n]
	infect = False
	pos = 0
	neg = 0
	for num in arr:
		if num < k:
			neg += k - num
		elif num > k:
			pos += num - k
		else:
			infect = True
	if pos == 0 and neg == 0:
		print(0)
	elif pos - neg == 0 or infect == True:
		print(1)
	else:
		print(2)


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for i in range(int(input())):
		(n, x) = inpt()
		ar = inpt()
		ok = True
		present = False
		for i in ar:
			if i == x:
				present = True
			if i != x:
				ok = False
		if ok:
			print(0)
		else:
			sm = 0
			for i in ar:
				sm += x - i
			if sm == 0 or present:
				print(1)
			else:
				print(2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	f = True
	g = False
	s = 0
	for i in range(n):
		if a[i] == x:
			g = True
		if a[i] != x:
			f = False
		s += a[i] - x
	if f:
		print(0)
	elif s == 0:
		print(1)
	elif g:
		print(1)
	else:
		print(2)


def solve():
	(n, x) = [int(v) for v in input().split()]
	arr = [int(v) for v in input().split()]
	if all((x == v for v in arr)):
		print(0)
	elif x in arr or sum((v - x for v in arr)) == 0:
		print(1)
	else:
		print(2)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	line = [int(n) for n in input().split(' ')]
	(n, x) = (line[0], line[1])
	arr = [int(n) for n in input().split(' ')]
	if sum([1 if y == x else 0 for y in arr]) > 0:
		if sum([1 if y == x else 0 for y in arr]) == n:
			print('0')
		elif sum([1 if y == x else 0 for y in arr]) > 1:
			print('1')
		else:
			one = False
			s = sum(arr)
			for i in range(1, n):
				sum_at_x = x * i
				remaining_sum = s - sum_at_x
				if remaining_sum % (n - i) == 0:
					one = True
			if one or (sum(arr) % len(arr) == 0 and sum(arr) // len(arr) == x):
				print('1')
			else:
				print('2')
	elif sum(arr) % len(arr) == 0 and sum(arr) // len(arr) == x:
		print('1')
	else:
		print('2')


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = [int(j) for j in input().split()]
	c = arr.count(x)
	if c == n:
		print(0)
		continue
	elif c > 0:
		print(1)
		continue
	net = 0
	for i in range(n):
		net += arr[i] - x
	if net == 0:
		print(1)
	else:
		print(2)


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		if all([x == ae for ae in a]):
			print(0)
		elif sum(a) / n == x:
			print(1)
		elif a.count(x) > 0:
			print(1)
		else:
			print(2)
main()


import sys

def multiple_input():
	return map(int, sys.stdin.readline().strip().split())

def list_input():
	return list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(n, x) = multiple_input()
	a = list_input()
	d = 0
	flag1 = 1
	flag2 = 0
	for i in a:
		if i != x:
			flag1 = 0
		else:
			flag2 = 1
		d += i - x
	if flag1:
		print(0)
	elif flag2:
		print(1)
	elif d == 0:
		print(1)
	else:
		print(2)


t = int(input())
while t:
	t = t - 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	flag = 0
	sum = 0
	flag0 = 1
	for i in a:
		if i != x:
			flag0 = 0
		sum += i - x
		if i == x:
			flag = 1
	if flag0:
		print(0)
	elif sum == 0 or flag:
		print(1)
	else:
		print(2)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	(*a,) = map(int, input().split())
	if a.count(x) == n:
		print(0)
	elif sum((x - i for i in a)) == 0 or a.count(x):
		print(1)
	else:
		print(2)


t = int(input())
for case in range(t):
	(n, x) = [int(s) for s in input().split(' ')]
	a = [int(s) for s in input().split(' ')]
	if set(a) == set([x]):
		ans = 0
	elif sum([b - x for b in a]) == 0 or x in a:
		ans = 1
	else:
		ans = 2
	print(ans)


def solve(n, x, arr):
	s = set(arr)
	if len(list(s)) == 1:
		if list(s)[0] == x:
			return 0
		else:
			return 2
	else:
		if x in s:
			return 1
		sm = 0
		for i in range(n):
			sm += x - arr[i]
		if sm == 0:
			return 1
		return 2
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	print(solve(n, x, arr))


import bisect
import math
import itertools
import sys
alpha = 'abcdefghijklmnopqrstuvwxyz'

def solve(n, x, arr):
	diff = 0
	for i in range(n):
		diff += x - arr[i]
	if diff:
		if x in arr:
			return 1
		else:
			return 2
		pass
	else:
		for i in range(n):
			if arr[i] != x:
				return 1
		return 0
	pass
t = int(input())
ans = []
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	ans.append(solve(n, x, arr))
for test in ans:
	print(test)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	c = 0
	su = 0
	for i in list(map(int, input().split())):
		if i == x:
			c += 1
		su += x - i
	if c == n:
		print(0)
	elif c == 0 and su != 0:
		print(2)
	else:
		print(1)


import sys
input = sys.stdin.readline
from math import ceil
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	a = True
	for i in lis:
		if i != x:
			a = False
			break
	if a:
		print(0)
	elif x in lis:
		print(1)
	elif ceil(sum(lis) / n) == int(sum(lis) / n) == x:
		print(1)
	else:
		print(2)


import os, sys
from io import BytesIO, IOBase

def main():
	for i in range(int(input())):
		(n, x) = map(int, input().split())
		a = [int(X) for X in input().split()]
		a.sort()
		if list(set(a)) == [x]:
			print(0)
		else:
			f = 0
			for j in a:
				if j == x:
					an = 1
					f = -1
					break
			if f == 0:
				if sum(a) == n * x:
					an = 1
				else:
					an = 2
			print(an)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	x = inlt()[1]
	accts = inlt()
	s = set(accts)
	if x in s:
		if len(s) == 1:
			print(0)
		else:
			print(1)
	elif sum([x - num for num in accts]) == 0:
		print(1)
	else:
		print(2)


t = int(input())
for q in range(0, t):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	flag = 0
	infect = 0
	for i in range(0, n):
		if a[i] != x:
			flag = 1
		else:
			infect = 1
	diff = [0] * n
	for i in range(0, n):
		diff[i] = x - a[i]
	s = sum(diff)
	if flag == 0:
		print(0)
	elif s == 0 or infect == 1:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	left = 0
	right = 0
	already = 0
	for i in range(n):
		if arr[i] > k:
			right += arr[i] - k
		elif arr[i] < k:
			left += k - arr[i]
		else:
			already += 1
	if left == 0 and right == 0:
		print(0)
	elif left == right or already > 0:
		print(1)
	else:
		print(2)


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '3\n2 69\n68 70\n6 4\n4 4 4 4 4 4\n9 38\n-21 83 50 -59 -77 15 -71 -78 20\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield input()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(a, killjoy):
	if all([x == killjoy for x in a]):
		return 0
	if any([x == killjoy for x in a]):
		return 1
	if sum([x - killjoy for x in a]) == 0:
		return 1
	return 2
t = getType(int)
for _ in range(t):
	(n, x) = getArray(int)
	a = getArray(int)
	res = solve(a, x)
	print(res)


t = int(input())
for test in range(t):
	(n, x) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	base_inf = 0
	diff = 0
	for a in arr:
		if a == x:
			base_inf += 1
		else:
			diff += a - x
	if base_inf == n:
		print(0)
	elif diff == 0 or base_inf >= 1:
		print(1)
	else:
		print(2)


import sys

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

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

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

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
for _ in range(INT()):
	(N, X) = MAP()
	A = LIST()
	se = set(A)
	if len(se) == 1 and list(se)[0] == X:
		print(0)
		continue
	cnt = 0
	for a in A:
		cnt += X - a
	if cnt == 0 or X in se:
		print(1)
	else:
		print(2)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, x) = list(map(int, input().split()))
		arry = list(map(int, input().split()))
		rem = []
		for i in range(n):
			if arry[i] != x:
				rem.append(arry[i])
		if len(rem) == 0:
			yield 0
		elif abs(sum(arry) / n - x) < 0.1 ** 10 or len(rem) != n:
			yield 1
		else:
			yield 2
t = int(input())
ans = gift()
print(*ans, sep='\n')


import sys
input = sys.stdin.readline
from math import gcd
from functools import reduce

def read():
	(N, X) = map(int, input().strip().split())
	A = list(map(int, input().strip().split()))
	return (N, X, A)

def solve(N, X, A):
	q = [a == X for a in A]
	if all(q):
		return 0
	if any(q) or sum(A) == N * X:
		return 1
	return 2
T = int(input().strip())
for t in range(T):
	inputs = read()
	print('%s' % solve(*inputs))


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
ANS = []
input = stdin.readline

def solve(n, x, arr):
	if set(arr) == set([x]):
		return 0
	g = 0
	summ = 0
	for i in range(n):
		summ += arr[i] - x
		if arr[i] == x:
			g = 1
			break
	if summ == 0 or g == 1:
		return 1
	else:
		return 2
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	ANS.append(str(solve(n, x, arr)))
print('\n'.join(ANS))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(i) - x for i in input().split()]
	if len(set(a)) == 1 and a[0] == 0:
		print(0)
	elif sum(a) == 0 or 0 in a:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	diff = sum(a) - n * x
	if diff == 0:
		if max(a) == min(a):
			print(0)
		else:
			print(1)
	elif x in a:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	tempA = [int(val) for val in input().split()]
	a = [val for val in tempA if val != x]
	if len(a) != n and len(a) != 0:
		print(1)
	else:
		result = 0
		if len(a) == 1:
			result += 1
		elif len(a) > 1:
			result += 1
			total = sum((x - val for val in a))
			if total != 0:
				for val in a:
					runningSum = total - (x - val)
					if -runningSum + val == x:
						break
				else:
					result += 1
		print(result)


def solve(ratings, n, r):
	if ratings.count(r) == n:
		print(0)
	elif ratings.count(r) > 0:
		print(1)
	elif sum(ratings) == r * n:
		print(1)
	else:
		print(2)

def main():
	t = int(input())
	for i in range(t):
		(n, r) = list(map(int, input().split()))
		solve(list(map(int, input().split())), n, r)
main()


def solve(n, x, a):
	c = a.count(x)
	if c == n:
		return 0
	if c > 0:
		return 1
	s = sum(a)
	if s % n == 0 and s / n == x:
		return 1
	return 2
tests = int(input())
for test in range(tests):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(solve(n, x, a))


def go():
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	diff = [a[i] - x for i in range(len(a))]
	flag = True
	f2 = False
	for i in range(len(diff)):
		if diff[i] != 0:
			flag = False
		if diff[i] == 0:
			f2 = True
	if flag:
		print(0)
		return
	if sum(diff) == 0 or f2:
		print(1)
		return
	print(2)
for tt in range(int(input())):
	go()


def che(l, x):
	b = True
	for i in range(f):
		if l[i] != x:
			b = False
			break
	return b
n = int(input())
for i in range(n):
	(f, x) = map(int, input().split())
	l = list(map(int, input().split()))[:f]
	if che(l, x) == True:
		print(0)
	elif x in l or sum(l) / f == x:
		print(1)
	elif x not in l and sum(l) / f != x:
		print(2)


from sys import stdin
for _ in range(int(input())):
	(n, m) = map(int, stdin.readline().rstrip().split(' '))
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	x = set(l)
	if m in x:
		if len(x) == 1:
			print(0)
		else:
			print(1)
	else:
		c = 0
		for i in range(n):
			c += l[i] - m
		if c == 0:
			print(1)
		else:
			print(2)


import math
t = int(input())
for w in range(t):
	(n, x) = (int(i) for i in input().split())
	l = [int(i) for i in input().split()]
	c1 = 0
	s = 0
	if l.count(x) == n:
		print(0)
	else:
		for i in range(n):
			s += l[i]
			if l[i] == x:
				c1 = 1
				break
		if c1 or s == n * x:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	(n, ra) = map(int, input().split())
	su = 0
	f = 1
	g = 0
	oth = list(map(int, input().split()))
	for a in range(n):
		f = f and oth[a] == ra
		g = g or oth[a] == ra
		su += oth[a] - ra
	if f:
		print(0)
	elif su == 0 or g:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = sum(l)
	if l.count(x) == n:
		print(0)
		continue
	if s == n * x or l.count(x) > 0:
		print(1)
		continue
	print(2)


import sys
import heapq
import copy
import math
import decimal
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	s = list(s[:len(s) - 1])
	s = [ord(s[i]) - ord('a') for i in range(len(s))]
	return s

def invr():
	return map(int, input().split())
ans = 0

def pr_list(a):
	print(*a, sep=' ')

def swap(a, b):
	temp = a
	a = b
	b = temp
	return [a, b]

def pri(a, b):
	s = '? ' + str(a) + ' ' + str(b)
	print(s)
	sys.stdout.flush()

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		[n, x] = inlt()
		a = inlt()
		same = 0
		for i in a:
			if i == x:
				same = same + 1
		if same == n:
			print(0)
			continue
		elif same >= 1:
			print(1)
			continue
		diff = 0
		for i in a:
			diff = diff + i - x
		if diff == 0:
			print(1)
		else:
			print(2)
main()


for ik in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	se = set(l)
	if n == 1:
		if l[0] == k:
			print(0)
		else:
			print(1)
	if l[0] == l[-1] == k:
		print(0)
	elif sum(l) == n * k:
		print(1)
	elif k in se:
		print(1)
	else:
		print(2)


import sys
from collections import deque
pprint = lambda s: print(' '.join(map(lambda x: str(x), s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = a.count(x)
	if l == n:
		print(0)
		continue
	elif l > 1:
		print(1)
	elif l == 1:
		print(1)
	elif sum(a) % n == 0 and sum(a) // n == x:
		print(1)
	else:
		print(2)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	if arr.count(x) == n:
		print(0)
	else:
		my_sum = 0
		f = 0
		for i in arr:
			if i == x:
				f = 1
				break
			else:
				my_sum += x - i
		if my_sum == 0 or f:
			print(1)
		else:
			print(2)


from collections import Counter
cases = int(input())
for t in range(cases):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = [x - i for i in a]
	lb = sum(b)
	b = Counter(b)
	v = b.get(0, 0)
	if v:
		if v == n:
			print(0)
		else:
			print(1)
	elif lb == 0:
		print(1)
	else:
		print(2)


t = int(input())
for zzz in range(t):
	output = 2
	flag = True
	(numAccounts, killjoysRating) = map(int, input().split())
	rankings = list(map(int, input().split()))
	if list(set(rankings)) == [killjoysRating]:
		print(0)
		continue
	if sum(rankings) / len(rankings) == killjoysRating:
		print(1)
		continue
	if killjoysRating in rankings:
		print(1)
		continue
	print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = s = 0
	for i in range(n):
		if a[i] == x:
			c += 1
		s += a[i]
	if c == n:
		print(0)
	elif c >= 1:
		print(1)
	elif s == n * x:
		print(1)
	else:
		print(2)


import bisect
from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	(n, x) = map(int, input().split())
	change = 0
	l = list(map(int, input().split()))
	cou = 0
	for i in l:
		if i == x:
			cou += 1
		change += i - x
	if cou == n:
		print(0)
	elif cou >= 1:
		print(1)
	elif change == 0:
		print(1)
	else:
		print(2)
	t -= 1


import math
for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	ratings = [int(i) for i in input().split()]
	unique = set(ratings)
	if unique == {x}:
		print(0)
	elif sum(ratings) / n == x or x in unique:
		print(1)
	else:
		print(2)


from __future__ import division, print_function
import sys
sys.setrecursionlimit(10 ** 4)
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f

def primeFactors(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			a.append(i)
			n = n // i
	if n > 2:
		a.append(n)
	return a

def main():
	t = inin()
	for _ in range(t):
		(n, x) = cin()
		a = ain()
		b = list(set(a))
		if len(b) == 1 and b[0] == x:
			print(0)
		elif sum(a) == n * x or x in a:
			print(1)
		else:
			print(2)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'R'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'R'[0]:
		A.append(sign * numb)
	return A
main()


T = int(input())
for Tid in range(T):
	(n, x) = map(int, input().split())
	s = -1 * n * x
	a = list(map(int, input().split()))
	flag = 1
	flag1 = 0
	for i in range(n):
		if a[i] != x:
			flag = 0
		else:
			flag1 = 1
		s = s + a[i]
	if flag:
		print(0)
	elif s == 0 or flag1 == 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	b = list(map(int, input().split()))
	a = set(b)
	if len(a) == 1 and b[0] == x:
		print(0)
	else:
		balance = 0
		flag = 0
		for i in b:
			balance += x - i
			if i == x:
				flag = 1
		if balance == 0 or flag == 1:
			print(1)
		else:
			print(2)


from math import inf
from collections import defaultdict

def main():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		if len(set(a)) == 1 and a[0] == x:
			print(0)
			continue
		s = 0
		ans = 0
		for i in range(n):
			if a[i] - x == 0:
				ans = 1
				break
			s += a[i] - x
		if s == 0:
			ans = 1
		if ans:
			print(1)
			continue
		print(2)
main()


t = int(input())
buf = []
for _ in range(t):
	(n, x) = map(int, input().split())
	aaa = list(map(int, input().split()))
	exists_same = False
	exists_different = False
	total = 0
	for a in aaa:
		a -= x
		if a == 0:
			exists_same = True
			continue
		exists_different = True
		total += a
	if not exists_different:
		buf.append(0)
	elif total == 0 or exists_same:
		buf.append(1)
	else:
		buf.append(2)
print('\n'.join(map(str, buf)))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	_sum = 0
	if arr.count(x) == len(arr):
		print(0)
		continue
	for i in arr:
		_sum += x - i
	if _sum == 0 or arr.count(x) > 0:
		print(1)
	else:
		print(2)


def Solve(data, y):
	x = set(data)
	if len(x) == 1 and y in x:
		return 0
	elif y in x:
		return 1
	elif sum(data) - len(data) * y == 0:
		return 1
	else:
		return 2

def main():
	t = int(input())
	while t > 0:
		t -= 1
		(n, x) = map(int, input().split())
		data = list(map(int, input().split()))
		print(Solve(data, x))
main()


from math import *
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	f = 0
	for i in range(n):
		if a[i] != x:
			break
	else:
		print(0)
		continue
	s = 0
	for i in range(n):
		if a[i] == x:
			f = 1
		a[i] = x - a[i]
		s = s + a[i]
	if s == 0 or f == 1:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	ans = 0
	for i in arr:
		if i != x:
			ans = 1
			break
	if ans == 0:
		print(ans)
		continue
	delta = 0
	for i in arr:
		delta += x - i
	if delta == 0:
		print(1)
		continue
	boo = 0
	for i in arr:
		if i == x:
			boo = 1
			break
	if boo:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(n, p) = map(int, input().split())
	b = list(map(int, input().split()))
	if b.count(p) == n:
		print(0)
	elif b.count(p) > 0:
		print(1)
	elif sum(b) == n * p:
		print(1)
	else:
		print(2)


TC = int(input())
for tc in range(TC):
	(N, X) = map(int, input().split())
	A = list(map(int, input().split()))
	c = A.count(X)
	if c == N:
		print(0)
	else:
		tr = sum(A)
		if tr == X * N or c > 0:
			print(1)
		else:
			print(2)


for query in range(int(input())):
	nx = input().split()
	n = int(nx[0])
	x = int(nx[1])
	a = [int(x) for x in input().split()]
	b = 0
	for y in range(n):
		if a[y] == x:
			b += 1
	if b == n:
		print(0)
		continue
	if b >= 1 or sum(a) == n * x:
		print(1)
		continue
	print(2)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	diff = []
	s = 0
	for j in range(n):
		if x - arr[j] == 0:
			s += 1
		diff.append(x - arr[j])
	a = sum(diff)
	if a == 0:
		z = arr[0]
		y = arr[-1]
		if z == y and x == y:
			print(0)
		else:
			print(1)
	elif s > 0:
		print(1)
	else:
		print(2)


def answer(n, x, A):
	count1 = 0
	for i in range(n):
		if A[i] == x:
			count1 += 1
	if count1 == n:
		return 0
	elif count1 >= 1:
		return 1
	count = 0
	for i in range(n):
		count += x - A[i]
	if count == 0:
		return 1
	else:
		return 2
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	print(answer(n, x, A))


def iinput():
	return int(input())

def finput():
	return float(input())

def linput():
	return [int(_) for _ in input().split()]
T = iinput()
for _ in range(T):
	(n, x) = linput()
	a = linput()
	(pos, neg) = (0, 0)
	flag = False
	for i in a:
		if i > x:
			pos += i - x
		elif i < x:
			neg += x - i
		else:
			flag = True
	if pos == 0 and neg == 0:
		print(0)
	elif pos == neg or flag:
		print(1)
	else:
		print(2)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	c = 0
	while x in lis:
		c += 1
		lis.remove(x)
	n = len(lis)
	if n == 0:
		print(0)
		continue
	if c > 0:
		print(1)
		continue
	c = 0
	for i in lis:
		c += x - i
	if c == 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	k = []
	c = 0
	for i in l:
		if i != x:
			k.append(i)
			c += 1
	s = set(k)
	if len(s) == 0:
		print(0)
		continue
	if c != n:
		print(1)
		continue
	ans = 0
	for i in k:
		ans += x - i
	if ans == 0:
		print(1)
	else:
		print(2)


for q in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(0 if sum([1 for i in range(n) if a[i] == x]) == n else 1 if any([1 for i in range(n) if a[i] == x]) or sum([a[i] - x for i in range(n)]) == 0 else 2)


import sys
input = sys.stdin.readline

def solve(n, x, nums):
	if [x] * n == nums:
		return 0
	elif sum((num - x for num in nums)) == 0 or x in nums:
		return 1
	else:
		return 2
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	nums = list(map(int, input().split()))
	print(solve(n, x, nums))


t = int(input())

def killjoy(n, x, arr):
	(Sum, Count) = (0, 0)
	for i in range(n):
		if arr[i] == x:
			Count += 1
		Sum += arr[i]
	if Count == n:
		return 0
	elif Count > 0 or x * n == Sum:
		return 1
	return 2
for i in range(t):
	(n, x) = input().split()
	arr = list(map(int, input().split()))
	print(killjoy(int(n), int(x), arr))


import sys
readline = sys.stdin.readline

def inlt():
	return list(map(int, readline().split()))

def ingen():
	return map(int, readline().split())

def insr():
	s = readline()
	return list(s)

def inn():
	return int(readline())
cases = inn()
for i in range(cases):
	(N, X) = inlt()
	scores = inlt()
	found_x = False
	found_not_x = False
	acc = 0
	res = None
	for i in range(N):
		if scores[i] == X:
			found_x = True
		if scores[i] != X:
			found_not_x = True
		acc += X - scores[i]
	if found_x and found_not_x:
		res = 1
	elif found_x and (not found_not_x):
		res = 0
	elif not found_x and found_not_x:
		if acc == 0:
			res = 1
		else:
			res = 2
	else:
		res = 3
	print(res)


t = int(input())
while t != 0:
	(n, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	s = 0
	f = 0
	set1 = set()
	for i in range(len(list1)):
		p = x - list1[i]
		if p == 0:
			f = 1
		s += p
		set1.add(p)
	if f == 1 and len(set1) == 1:
		print(0)
	elif s == 0 or f == 1:
		print(1)
	else:
		print(2)
	t -= 1


for t in range(int(input())):
	diff_arr = []
	total_days = 0
	(p, x) = map(int, input().split())
	ratings = list(map(int, input().split()))
	all_same = True
	total_d = 0
	already_infected = False
	for r in ratings:
		v = x - r
		total_d -= v
		if r != x:
			all_same = False
		else:
			already_infected = True
	if all_same:
		total_days = 0
	elif total_d == 0 or already_infected:
		total_days = 1
	else:
		total_days = 2
	print(total_days)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt

def solve():
	(n, x) = read()
	a = get_list()
	b = a.count(x)
	if b == n:
		print(0)
		return
	s = sum(map(int, [x - y for y in a]))
	if s == 0 or b > 0:
		print(1)
	else:
		print(2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


import sys
input = sys.stdin.buffer.readline

def solution():
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if l.count(x) == n:
		print(0)
	elif l.count(x) > 0:
		print(1)
	else:
		s = 0
		for i in range(n):
			s += x - l[i]
		if s == 0:
			print(1)
		else:
			print(2)
t = int(input())
for _ in range(t):
	solution()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if len(set(a)) == 1 and a[0] == x:
		print(0)
	elif x in a:
		print(1)
	else:
		d = 0
		for i in range(0, n):
			d += a[i] - x
		if d == 0:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) == n * x:
		flag = False
		for rating in a:
			if rating != x:
				flag = True
				break
		if flag:
			print(1)
		else:
			print(0)
	else:
		flag = False
		for rating in a:
			if rating == x:
				flag = True
				break
		if flag:
			print(1)
		else:
			print(2)


def count_x(arr, n, x):
	count = 0
	for i in range(n):
		if arr[i] == x:
			count += 1
	return count

def deviation(arr, n, x):
	result = 0
	for i in range(n):
		result += arr[i] - x
	return result

def kill_joy(arr, n, x):
	infected_count = count_x(arr, n, x)
	if infected_count == n:
		return 0
	elif infected_count != 0:
		return 1
	elif deviation(arr, n, x) == 0:
		return 1
	else:
		return 2
t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	print(kill_joy(arr, n, x))


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

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

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, x, lst):
	sameX = 0
	for i in lst:
		if i == x:
			sameX += 1
	if sameX == n:
		return 0
	if sameX != 0:
		return 1
	delta = 0
	for i in range(n - 1):
		delta += lst[i] - x
	if lst[-1] + delta == x:
		return 1
	return 2
for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	print(solve(n, x, lst))


for j in range(int(input())):
	(n, vir) = input().split()
	a = [int(x) for x in input().split()]
	(neg, pos) = (0, 0)
	if all(map(lambda x: x == int(vir), a)):
		print(0)
	elif any(map(lambda x: x == int(vir), a)):
		print(1)
	else:
		for i in a:
			if i < int(vir):
				neg += abs(int(vir) - i)
			else:
				pos += abs(i - int(vir))
		if neg == pos:
			print(1)
		else:
			print(2)


def iinput():
	return [int(i) for i in input().split()]
t = int(input())
for _ in range(t):
	(n, x) = iinput()
	mas = iinput()
	if set(mas) == set(list([x])):
		print(0)
	elif sum(mas) / n == x or x in mas:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	if sum(l) == n * x:
		if l[0] == x:
			print(0)
		else:
			print(1)
	elif x in l:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(N, x) = map(int, input().split())
	A = list(map(int, input().split()))
	flag = 0
	for i in A:
		if i != x:
			flag = 1
			break
	if flag != 0:
		ans = 0
		v = 0
		for i in range(N):
			ans = ans + A[i]
			if A[i] == x:
				v = v + 1
		if ans == x * N:
			flag = 1
		elif v > 0:
			flag = 1
		else:
			flag = 2
	print(flag)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	(n, x) = get_tuple()
	ls = get_list()
	cnt = ls.count(x)
	diff = 0
	for val in ls:
		diff += x - val
	if cnt == n:
		print(0)
	elif cnt >= 1 or diff == 0:
		print(1)
	else:
		print(2)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	a = 0
	b = 0
	for i in l:
		if i == k:
			a += 1
		else:
			b += 1
	if a == n:
		print(0)
	elif a > 0 or sum(l) == n * k:
		print(1)
	else:
		print(2)


from collections import Counter
for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	k = 0
	c = 0
	for i in l:
		k += x - i
		if i == x:
			c += 1
	if c == n:
		print(0)
	elif c >= 1:
		print(1)
	elif k == 0:
		print(1)
	else:
		print(2)


def solve():
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	sum = 0
	b = 0
	for i in lst:
		if i == x:
			b += 1
		sum += i
	if b == n:
		print(0)
		return 0
	if b >= 1:
		print(1)
		return 0
	if sum == x * n:
		print(1)
		return 0
	print(2)
for i in range(int(input())):
	solve()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ar = list(map(int, input().split()))
	flag = True
	for i in ar:
		if i != x:
			flag = False
			break
	if flag:
		print(0)
	else:
		su = 0
		for i in ar:
			su += x - i
		if su == 0:
			print(1)
		else:
			inf = 0
			unif = 0
			for i in ar:
				if i == x:
					inf += 1
				else:
					unif += 1
			if inf != 0:
				print(1)
			else:
				print(2)


from math import *
from random import *
from bisect import *
from math import *
for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	beg = 1
	for i in a:
		if i == x:
			beg += 1
	if beg == n + 1:
		print(0)
		continue
	if beg >= 2:
		print(1)
		continue
	sm = sum(a)
	if sm == x * n:
		print(1)
		continue
	print(2)


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	(n, x) = INL()
	A = INL()
	s = 0
	c = 0
	for _ in range(n):
		s += x - A[_]
		c += int(A[_] == x)
	if c == n:
		OPS(0)
	elif s == 0 or x in A:
		OPS(1)
	else:
		OPS(2)


import sys

def check(n, x, a):
	for h in range(n):
		if a[h] != x:
			return False
	return True
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	[n, x] = [int(j) for j in sys.stdin.readline().split()]
	a = [int(g) for g in sys.stdin.readline().split()]
	if check(n, x, a):
		ans_arr.append('0')
	elif x in a:
		ans_arr.append('1')
	elif sum(a) % n == 0 and sum(a) // n == x:
		ans_arr.append('1')
	else:
		ans_arr.append('2')
print('\n'.join(ans_arr))


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, X, A):
	if min(A) == max(A) == X:
		return 0
	if sum(A) == N * X:
		return 1
	if X in A:
		return 1
	return 2
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, X) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, X, A)
	print(ans)


def cont_req(x, ns):
	diff = 0
	diff_exists = False
	same_exists = False
	for n in ns:
		if n != x:
			diff_exists = True
		else:
			same_exists = True
		diff += n - x
	if diff == 0 and (not diff_exists):
		return 0
	elif diff != 0 and (not same_exists):
		return 2
	else:
		return 1
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ns = list(map(int, input().split()))
	print(cont_req(x, ns))


N = int(input())
for _ in range(N):
	(n, x) = list(map(int, input().split()))
	acs = []
	a = 0
	left = 0
	for y in list(map(int, input().split())):
		if y != x:
			left += y - x
			acs.append(y)
		else:
			a |= 1
	if not acs:
		print(0)
		continue
	if a or left == 0:
		print(1)
	else:
		print(2)


I = lambda : map(int, input().split())
(t,) = I()
for _ in [0] * t:
	(n, x) = I()
	(*s,) = I()
	print([0, 2 - (x in s or sum(s) == x * n)][{*s} != {x}])


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, x) = R()
	a = sorted(R())
	if a[0] == a[-1] == x:
		print(0)
	elif sum([x - i for i in a]) == 0 or x in a:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	values = list(map(int, input().split()))
	allX = True
	for i in range(n):
		if values[i] != x:
			allX = False
			break
	if allX:
		print(0)
	elif sum(values) / len(values) == x or x in values:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	li = [int(i) for i in input().split()]
	zero = True
	one = False
	tot = 0
	for i in li:
		tot += i
		if i != x:
			zero = False
		else:
			one = True
	if zero:
		print(0)
	elif n * x == tot:
		print(1)
	elif one:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	neg = 0
	pos = 0
	equal = 0
	for i in arr:
		if i < x:
			neg += x - i
		if i > x:
			pos += i - x
		if i == x:
			equal += 1
	if neg == 0 and pos == 0:
		print(0)
	elif neg == pos or equal > 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	left = 0
	right = 0
	innfected = 0
	for i in range(len(x)):
		if x[i] < k:
			left += k - x[i]
		elif x[i] == k:
			innfected += 1
		else:
			right += x[i] - k
	if left == 0 and right == 0:
		print(0)
	elif left == right or innfected > 0:
		print(1)
	else:
		print(2)


import sys
import random
from fractions import Fraction
from math import *

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

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return list(map(int, tinput()))

def fiinput():
	return list(map(float, tinput()))

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

def trinput():
	return tuple(rinput())

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

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	(n, k) = rinput()
	q = srlinput()
	print((q.count(k) != n) * (k in q) + (1 + (k * n != sum(q))) * (k not in q))
for i in range(iinput()):
	main()


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	some_val_equal_x = False
	some_val_not_equal_x = False
	[n, x] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	totalDiff = 0
	for val in arr:
		totalDiff += val - x
		if val == x:
			some_val_equal_x = True
		else:
			some_val_not_equal_x = True
	if some_val_not_equal_x == False:
		print(0)
	elif totalDiff == 0 or some_val_equal_x == True:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	sum1 = 0
	(n, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	flag = 0
	for i in lis:
		if i == x:
			flag += 1
	if flag == len(lis):
		print(0)
		continue
	if flag >= 1:
		print(1)
		continue
	for i in lis:
		sum1 += i - x
	if sum1 == 0:
		print(1)
	else:
		print(2)


from sys import stdin, stdout
from math import gcd, log2, log10, floor, ceil
import math
from collections import defaultdict, OrderedDict
from bisect import bisect_left

def same(l, x):
	res = 1
	for i in range(len(l)):
		if l[i] != x:
			res = 0
			break
	return res

def fun(n, x, l):
	if same(l, x):
		return 0
	for i in range(n):
		if l[i] == x:
			return 1
	count = 0
	for i in range(n - 1):
		count += l[i] - x
		l[i] = x
	l[-1] += count
	if l[-1] == x:
		return 1
	return 2
for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	answer = fun(n, x, l)
	print(answer)


q = int(input())
for _ in range(q):
	(n, x) = map(int, input().split())
	ar = [int(i) for i in input().split()]
	cnt = 0
	for el in ar:
		cnt += el == x
	if cnt == n:
		print(0)
	elif cnt > 0:
		print(1)
	else:
		cnt = 0
		for el in ar:
			cnt += x - el
		if cnt == 0:
			print(1)
		else:
			print(2)


import sys
from copy import *
from bisect import *

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	(n, x) = mi()
	a = li()
	for i in range(n):
		a[i] -= x
	if sum(a) == 0:
		if a.count(0) == n:
			print(0)
		else:
			print(1)
	elif a.count(0):
		print(1)
	else:
		print(2)


for t in range(int(input())):
	(n, inf) = map(int, input().split())
	rats = list(map(int, input().split()))
	if len(set(rats)) == 1 and rats[0] == inf:
		print(0)
	elif sum(rats) == n * inf or inf in rats:
		print(1)
	else:
		print(2)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	(n, x) = map(int, inputi().split())
	aa = [int(a) for a in inputi().split()]
	ic = aa.count(x)
	if ic == n:
		print(0)
		return
	sm = sum(aa)
	if sm == n * x:
		print(1)
		return
	if ic >= 1:
		print(1)
		return
	print(2)

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	(f1, f2) = (0, 0)
	for i in range(n):
		if l[i] == x:
			f1 = 1
		else:
			f2 = 1
	if f1 == 1 and f2 == 0:
		print(0)
	elif f1 == 1 and f2 == 1:
		print(1)
	elif f1 == 0 and f2 == 1:
		if sum(l) == x * n:
			print(1)
		else:
			print(2)


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	(n, x) = IP()
	a = L()
	diff = [0] * n
	for i in range(n):
		diff[i] = x - a[i]
	if diff == [0] * n:
		print(0)
	elif sum(diff) == 0:
		print(1)
	elif 0 in diff:
		print(1)
		return
	else:
		print(2)
		return
	return
t = II()
for i in range(t):
	solve()


from collections import defaultdict as dd
import math
import sys
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

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

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

def solve():
	(n, k) = mi()
	rats = lm()
	if all((r == k for r in rats)):
		print(0)
		return
	s = sum(rats)
	if s == k * n or any((r == k for r in rats)):
		print(1)
		return
	print(2)
	return
q = nn()
for _ in range(q):
	solve()


for i in range(0, int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)
	m = 0
	f = 0
	l = 0
	if a[0] == a[-1] == x:
		print('0')
	else:
		for j in a:
			if j < x:
				m += abs(x - j)
			elif j == x:
				l = 1
				break
			else:
				f += abs(x - j)
		if l == 1:
			print('1')
		elif m == f:
			print('1')
		else:
			print('2')


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	answer = 0
	e = 0
	for i in range(n):
		if a[i] == x:
			e += 1
	if e == n:
		print(0)
	elif e != 0:
		print(1)
	elif sum(a) % n == 0 and sum(a) // n == x:
		print(1)
	else:
		print(2)


def solve(a, x):
	if [x] * len(a) == a:
		return 0
	if x in a or sum(a) == x * len(a):
		return 1
	return 2
tc = int(input())
for _ in range(tc):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(solve(a, x))


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	ok1 = True
	ok2 = False
	for i in arr:
		if x != i:
			ok1 = False
		if i == x:
			ok2 = True
	if ok1:
		print(0)
	else:
		s = 0
		for i in arr:
			s += i - x
		if s == 0 or ok2:
			print(1)
		else:
			print(2)


import sys, math
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	(N, K) = getInts()
	A = getInts()
	diffs = 0
	K_count = 0
	for x in A:
		diffs += x - K
		K_count += x == K
	if K_count == N:
		return 0
	return 1 if diffs == 0 or K_count > 0 else 2
T = getInt()
for t in range(T):
	print(solve())


def process():
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	nz = 1
	atl_0 = 0
	for i in range(n):
		a[i] = a[i] - x
		if a[i] != 0:
			nz = 0
		if a[i] == 0:
			atl_0 = 1
	if nz == 1:
		print(0)
		return
	if sum(a) == 0 or atl_0 == 1:
		print(1)
	else:
		print(2)

def main():
	t = int(input())
	for i in range(t):
		process()
main()


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

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

def ma1():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	(n, x) = ma1()
	a = lis()
	diff = 0
	fl = 0
	se = set()
	ma = {}
	r = []
	ned = []
	pos = []
	fl = 0
	for i in a:
		if i != x:
			fl += 0
		else:
			fl += 1
		if x - i > 0:
			pos.append(x - i)
		else:
			ned.append(x - i)
	if fl == n:
		print(0)
		continue
	else:
		z = sum(pos)
		x = sum(ned)
		if x == -z or fl:
			print(1)
			continue
		print(2)


import os, sys
from io import BytesIO, IOBase
from sys import setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
setrecursionlimit(100000)
mod = 1000000007

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	for _ in range(inp()):
		(n, x) = invr()
		a = inlt()
		su = sum(a)
		b = a.count(x)
		if b == n:
			print(0)
		elif not b:
			if su == n * x:
				print(1)
			else:
				print(2)
		else:
			print(1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(0, t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * n
	sum = 0
	m = 0
	for i in range(0, n):
		if a[i] == x:
			m = 1
	for i in range(0, n):
		a[i] = x - a[i]
	if a == b:
		print(0)
	else:
		for i in range(0, n):
			sum = sum + a[i]
		if sum == 0 or m == 1:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	(n, x) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	infeteced = [ai == x for ai in a]
	diff = [0 if ai_infected else ai - x for (ai, ai_infected) in zip(a, infeteced)]
	if all((v == x for v in a)):
		print(0)
	elif sum(diff) == 0 or sum(infeteced) > 0:
		print(1)
	else:
		print(2)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	(n, x) = value()
	a = arr()
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	if d[x] > 0:
		if len(d.keys()) == 1:
			print(0)
		else:
			print(1)
	else:
		sm = 0
		for i in a:
			sm += x - i
		if sm == 0:
			print(1)
		else:
			print(2)


def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for i in range(n):
	l = inlt()
	m = l[0]
	killjoy = l[1]
	l = inlt()
	same = 0
	accul = 0
	for x in l:
		if x == killjoy:
			same += 1
		accul += x
	if same == len(l):
		print(0)
	elif accul == killjoy * m or same > 0:
		print(1)
	else:
		print(2)


def solve(n, k, rs):
	rating_ne = []
	for rate in rs:
		if rate != k:
			rating_ne.append(rate)
	if not rating_ne:
		return 0
	if sum(rating_ne) == k * len(rating_ne) or n > len(rating_ne):
		return 1
	return 2
N = int(input())
for i in range(N):
	(nc, killjoy) = list(map(int, input().split()))
	ratings = list(map(int, input().split()))
	print(solve(nc, killjoy, ratings))


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if len(set(a)) == 1 and a[0] == x:
		print(0)
	elif sum(a) // n == sum(a) / n and sum(a) // n == x:
		print(1)
	elif a.count(x) > 0:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	inc = 0
	dec = 0
	one = False
	for x in arr:
		aux = x - k
		if aux == 0:
			one = True
		elif aux < 0:
			inc -= aux
		elif aux > 0:
			dec += aux
	if inc == dec == 0:
		print(0)
	elif inc == dec or one:
		print(1)
	else:
		print(2)


import sys
readline = sys.stdin.readline
INF = 1 << 60

def read_int():
	return int(readline())

def read_int_n():
	return list(map(int, readline().split()))

def read_float():
	return float(readline())

def read_float_n():
	return list(map(float, readline().split()))

def read_str():
	return readline().strip()

def read_str_n():
	return readline().strip().split()

def ep(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.perf_counter()
		ret = f(*args, **kwargs)
		e = time.perf_counter()
		ep(e - s, 'sec')
		return ret
	return wrap

def slv(N, X, A):
	if len(set(A) - {X}) == 0:
		return 0
	d = 0
	for a in A:
		d += X - a
	if d == 0:
		return 1
	if X in A:
		return 1
	return 2

def main():
	for _ in range(read_int()):
		(N, X) = read_int_n()
		A = read_int_n()
		print(slv(N, X, A))
main()


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	flag = True
	flag1 = False
	for i in a:
		if i != x:
			flag = False
		if i == x:
			flag1 = True
		c += x - i
	if flag:
		print(0)
	elif c == 0 or flag1 == True:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	c = 0
	d = a.count(x)
	for i in a:
		c += x - i
	if d == n:
		print('0')
	elif c == 0 or a.count(x) > 0:
		print('1')
	else:
		print('2')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) == n * x:
		if min(l) == x:
			print(0)
		else:
			print(1)
	elif any((v == x for v in l)):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, rate) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	t = 0
	am = 0
	q = 0
	for i in range(n):
		if arr[i] == rate:
			q += 1
		else:
			t += arr[i]
			am += 1
	if n == q:
		print(0)
	elif q >= 1 or t / am == rate:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if all([ele == x for ele in l]):
		print(0)
		continue
	if sum(l) == n * x or any([ele == x for ele in l]):
		print(1)
		continue
	print(2)


import sys
input = sys.stdin.buffer.readline
T = int(input())
for testcase in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(a)
	if x in b:
		if len(b) == 1:
			print(0)
		else:
			print(1)
	else:
		s = sum(a)
		if s == x * n:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	(l, r) = map(int, input().split())
	a = list(map(int, input().split()))
	a = [r - a[j] for j in range(l)]
	p = sum(a)
	if p == 0 and len(set(a)) == 1:
		print(0)
	elif p == 0 or 0 in a:
		print(1)
	else:
		print(2)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	if arr.count(x) == n:
		print(0)
		continue
	diff = 0
	for i in range(n):
		diff += x - arr[i]
	if diff == 0:
		print(1)
	elif arr.count(x) == 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	if a[0] == k and len(set(a)) == 1:
		print('0')
		continue
	if k in a or sum(a) - n * k == 0:
		print('1')
		continue
	print('2')


t = int(input())
for _ in range(t):
	[n, x] = [int(p) for p in input().split()]
	a = [int(p) for p in input().split()]
	avg = sum(a) / n
	t = 1
	if avg == x:
		if min(a) == x:
			print(0)
		else:
			print(1)
	elif x in a:
		print(1)
	else:
		print(2)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(n, x) = inp()
	arr = list(inp())
	arr2 = list(arr)
	arr = [x - i for i in arr]
	test = [0] * n
	if arr == test:
		ans = 0
	elif sum(arr) == 0:
		ans = 1
	else:
		flag = False
		for i in arr2:
			if i == x:
				flag = True
		if flag:
			ans = 1
		else:
			ans = 2
	out(ans)


import sys
input = sys.stdin.readline

def print(val):
	sys.stdout.write(str(val) + '\n')

def prog():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		fail = False
		had_one = False
		for i in range(n):
			if a[i] != x:
				fail = True
				break
		for i in range(n):
			if a[i] == x:
				had_one = True
		if not fail:
			print(0)
		else:
			s = sum(a)
			if s == x * n or had_one:
				print(1)
			else:
				print(2)
prog()


test_num = int(input())

def solve():
	(n, x) = map(int, input().split())
	accounts = list(map(int, input().split()))
	has_equal = False
	has_unequal = False
	acc_sum = 0
	for account in accounts:
		if account == x:
			has_equal = True
		else:
			has_unequal = True
		acc_sum += account
	if not has_unequal:
		print(0)
	elif has_equal or acc_sum == n * x:
		print(1)
	else:
		print(2)
for i in range(test_num):
	solve()


def f():
	t = int(input())
	arr = []
	for _ in range(t):
		(n, x) = tuple(map(int, input().split()))
		arr.append((n, x, tuple(map(int, input().split()))))
	for (n, x, ratings) in arr:
		infected = sum([1 for r in ratings if r == x])
		if infected == n:
			print(0)
		elif sum(ratings) == x * n or infected >= 1:
			print(1)
		else:
			print(2)
f()


t = int(input())
ans = []
for i in range(0, t):
	cnt = 0
	d = 0
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	a = input().split()
	for i in range(0, n):
		a[i] = int(a[i])
	for i in range(0, n):
		d = d + a[i] - x
		if a[i] == x:
			cnt += 1
	if cnt == n:
		ans.append(0)
	elif cnt > 0:
		ans.append(1)
	elif d == 0:
		ans.append(1)
	else:
		ans.append(2)
for i in range(0, t):
	print(ans[i])


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	f = False
	if len(set(l)) == 1 and l[0] == x:
		print(0)
		continue
	ne = po = 0
	for i in l:
		if i == x:
			f = True
			break
		elif x - i > 0:
			po += x - i
		else:
			ne += x - i
	if f or abs(po) == abs(ne):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	if len(set(arr)) == 1 and arr[0] == x:
		print(0)
	elif x in arr:
		print(1)
	else:
		sm = 0
		for num in arr:
			sm += num - x
		if sm == 0:
			print(1)
		else:
			print(2)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().rstrip('\n\r')
_T_ = inin()
for _t_ in range(_T_):
	(n, x) = inar()
	a = inar()
	if set(a) == {x}:
		print(0)
	elif sum(a) / n == x:
		print(1)
	elif a.count(x) > 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	(d, k) = (0, 0)
	for i in range(n):
		d += m - lst[i]
		if lst[i] == m:
			k += 1
	if d == 0:
		print(0 if k == n else 1)
	else:
		print(1 if k >= 1 else 2)


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	acc = 0
	res = 0
	changed = False
	detector = False
	for i in range(n):
		acc += x - a[i]
		if x - a[i] == 0:
			detector = True
		a[i] = x
		if acc != 0:
			changed = True
	if changed:
		res += 1
	if acc != 0 and (not detector):
		res += 1
	print(res)


from enum import *
from copy import *
from sys import *
from collections import *
from itertools import *
from functools import *
from math import *

def l2i(fr=None):
	return map_type_to_fr(int, fr)[0]

def i2i(fr=None):
	return l2i(fr)

def dbg(*args):
	print(*args, file=stderr)

def dbv(var_name):
	print(f'{var_name} = {eval(var_name)}', file=stderr)

def map_type_to_fr(t, fr):
	global GETLINE_OFFSET
	if fr is None:
		if RUNNING_ON_MY_PC:
			fr = TEST_INP[GETLINE_OFFSET].split()
			GETLINE_OFFSET += 1
		else:
			fr = input().split()
	return list(map(t, fr))

def mis(fr=None):
	return map_type_to_fr(int, fr)

def mbs(fr=None):
	return map_type_to_fr(bool, fr)

def gs(fr=None):
	return map_type_to_fr(str, fr)[0]
import os
import sysconfig
RUNNING_ON_MY_PC = os.name == 'nt' and platform == 'win32' and (sysconfig.get_platform() == 'win-amd64')
GETLINE_OFFSET = 0
TEST_INP = '1\n9 38\n-21 83 50 -59 -77 15 -71 -78 20\n\n'.split('\n')

def my_r(x):
	c = ceil(x)
	if c - x > 0.5:
		return floor(x)
	return c
t = i2i()
for _ in range(t):
	(n, x) = mis()
	a = mis()
	mx = float('-inf')
	mn = float('inf')
	sd = 0
	avg = x
	b = False
	for el in a:
		mx = max(mx, el)
		mn = min(mn, el)
		d = el - avg
		if d == 0:
			b = True
		sd += d
	if mx == mn == x:
		print(0)
		continue
	if sd == 0 or b:
		print(1)
		continue
	print(2)
	continue


t = int(input())
while t:
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if a == [x] * n:
		print(0)
	elif sum(a) - n * x == 0:
		print(1)
	else:
		flag = 0
		for y in range(n):
			if a[y] == x:
				flag = 1
				break
		if flag:
			print(1)
		else:
			print(2)
	t -= 1