# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
K =[0]*N
A=[]
for i in range(N):
    a,*b = list(map(int, input().split()))
    K[i] =a
    A.append(set(b))
ans =set(list(A[0]))
for i in A:
    ans &=i
print(len(ans)) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N,M = (int(i) for i in input().split()) N (int(i) for i in input().split()) M K =[0]*N K [0]*N [0] 0 N A=[] A [] for i in range(N):
    a,*b = list(map(int, input().split()))
    K[i] =a
    A.append(set(b)) i range(N) range N a,*b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split *b b K[i] =a K[i] K i a A.append(set(b)) A.append A append set(b) set b ans =set(list(A[0])) ans set(list(A[0])) set list(A[0]) list A[0] A 0 for i in A:
    ans &=i i A ans &=i ans i print(len(ans)) print len(ans) len ans input = sys.stdin.readline sys.stdin.readline input N,M = (int(i) for i in input().split()) (int(i) for i in input().split()) N a,*b = list(map(int, input().split())) list(map(int, input().split())) a ans =set(list(A[0])) set(list(A[0])) ans M = (int(i) for i in input().split()) (int(i) for i in input().split()) M K =[0]*N [0]*N K ans &=i i ans A=[] [] A
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
K =[0]*N
A=[]
for i in range(N):
    a,*b = list(map(int, input().split()))
    K[i] =a
    A.append(set(b))
ans =set(list(A[0]))
for i in A:
    ans &=i
print(len(ans))