N,M = map(int,input().split())
target = list()
for i in range(N):
	target_list = list(map(int,input().split()))
	target_list.pop(0)
	target.append(target_list)

# print(target)

ans = dict()
for i in range(0,len(target)):
	for j in range(len(target[i])):
		if i == 0:
			ans[target[i][j]] = 1
		else:
			if target[i][j] in ans:
				ans[target[i][j]] += 1

ans_num = 0
for k in ans.keys():
	if ans[k] == N:
		ans_num += 1
print(ans_num) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M target = list() target list() list for i in range(N):
	target_list = list(map(int,input().split()))
	target_list.pop(0)
	target.append(target_list)

# print(target) i range(N) range N target_list = list(map(int,input().split())) target_list list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split target_list.pop(0) target_list.pop target_list pop 0 target.append(target_list) target.append target append target_list ans = dict() ans dict() dict for i in range(0,len(target)):
	for j in range(len(target[i])):
		if i == 0:
			ans[target[i][j]] = 1
		else:
			if target[i][j] in ans:
				ans[target[i][j]] += 1 i range(0,len(target)) range 0 len(target) len target for j in range(len(target[i])):
		if i == 0:
			ans[target[i][j]] = 1
		else:
			if target[i][j] in ans:
				ans[target[i][j]] += 1 j range(len(target[i])) range len(target[i]) len target[i] target i if i == 0:
			ans[target[i][j]] = 1
		else:
			if target[i][j] in ans:
				ans[target[i][j]] += 1 i == 0 i 0 ans[target[i][j]] = 1 ans[target[i][j]] ans target[i][j] [i] target i j 1 if target[i][j] in ans:
				ans[target[i][j]] += 1 target[i][j] in ans target[i][j] [i] target i j ans ans[target[i][j]] += 1 ans[target[i][j]] ans target[i][j] [i] target i j 1 ans_num = 0 ans_num 0 for k in ans.keys():
	if ans[k] == N:
		ans_num += 1 k ans.keys() ans.keys ans keys if ans[k] == N:
		ans_num += 1 ans[k] == N ans[k] ans k N ans_num += 1 ans_num 1 print(ans_num) print ans_num N,M = map(int,input().split()) map(int,input().split()) N target = list() list() target ans = dict() dict() ans ans_num = 0 0 ans_num ans_num += 1 1 ans_num target_list = list(map(int,input().split())) list(map(int,input().split())) target_list M = map(int,input().split()) map(int,input().split()) M
N,M = map(int,input().split())
target = list()
for i in range(N):
	target_list = list(map(int,input().split()))
	target_list.pop(0)
	target.append(target_list)

# print(target)

ans = dict()
for i in range(0,len(target)):
	for j in range(len(target[i])):
		if i == 0:
			ans[target[i][j]] = 1
		else:
			if target[i][j] in ans:
				ans[target[i][j]] += 1

ans_num = 0
for k in ans.keys():
	if ans[k] == N:
		ans_num += 1
print(ans_num)
