N,M=map(int,input().split())
cnt=[0 for _ in range(M)]
for _ in range(N):
    A=list(map(int,input().split()))
    for j in range(1,A[0]+1):
        cnt[A[j]-1]+=1
print(cnt.count(N)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M 0 for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) 0 cnt=[0 for _ in range(M)] cnt [0 for _ in range(M)] for _ in range(N):
    A=list(map(int,input().split()))
    for j in range(1,A[0]+1):
        cnt[A[j]-1]+=1 _ range(N) range N A=list(map(int,input().split())) A list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in range(1,A[0]+1):
        cnt[A[j]-1]+=1 j range(1,A[0]+1) range 1 A[0]+1 A[0] A 0 1 cnt[A[j]-1]+=1 cnt[A[j]-1] cnt A[j]-1 A[j] A j 1 1 print(cnt.count(N)) print cnt.count(N) cnt.count cnt count N M=map(int,input().split()) map(int,input().split()) M N,M=map(int,input().split()) map(int,input().split()) N A=list(map(int,input().split())) list(map(int,input().split())) A cnt=[0 for _ in range(M)] [0 for _ in range(M)] cnt
N,M=map(int,input().split())
cnt=[0 for _ in range(M)]
for _ in range(N):
    A=list(map(int,input().split()))
    for j in range(1,A[0]+1):
        cnt[A[j]-1]+=1
print(cnt.count(N))
