MM = input().split()
N =int(MM[0])
M =int(MM[1])
list1 = [i for i in range(M+1)]
for i in range(N):
  MM = input().split()
  list2 = [int(MM[j]) for j in range(1,int(MM[0])+1)]
  list1 = set(list1)&set(list2)
print(len(list1)) MM = input().split() MM input().split() ().split () input split N =int(MM[0]) N int(MM[0]) int MM[0] MM 0 M =int(MM[1]) M int(MM[1]) int MM[1] MM 1 i for i in range(M+1) for i in range(M+1) i range(M+1) range M+1 M 1 for i in range(M+1) i list1 = [i for i in range(M+1)] list1 [i for i in range(M+1)] for i in range(N):
  MM = input().split()
  list2 = [int(MM[j]) for j in range(1,int(MM[0])+1)]
  list1 = set(list1)&set(list2) i range(N) range N MM = input().split() MM input().split() ().split () input split int(MM[j]) for j in range(1,int(MM[0])+1) for j in range(1,int(MM[0])+1) j range(1,int(MM[0])+1) range 1 int(MM[0])+1 int(MM[0]) int MM[0] MM 0 1 for j in range(1,int(MM[0])+1) int(MM[j]) int MM[j] MM j list2 = [int(MM[j]) for j in range(1,int(MM[0])+1)] list2 [int(MM[j]) for j in range(1,int(MM[0])+1)] list1 = set(list1)&set(list2) list1 set(list1)&set(list2) set(list1) set list1 set(list2) set list2 print(len(list1)) print len(list1) len list1 MM = input().split() input().split() MM list1 = set(list1)&set(list2) set(list1)&set(list2) list1 N =int(MM[0]) int(MM[0]) N M =int(MM[1]) int(MM[1]) M list1 = [i for i in range(M+1)] [i for i in range(M+1)] list1 MM = input().split() input().split() MM list2 = [int(MM[j]) for j in range(1,int(MM[0])+1)] [int(MM[j]) for j in range(1,int(MM[0])+1)] list2
MM = input().split()
N =int(MM[0])
M =int(MM[1])
list1 = [i for i in range(M+1)]
for i in range(N):
  MM = input().split()
  list2 = [int(MM[j]) for j in range(1,int(MM[0])+1)]
  list1 = set(list1)&set(list2)
print(len(list1))
