import numpy as np
N,M = map(int,input().split())
A = [[int(i) for i in input().split()] for _ in range(N)]

ans=0
for i in range(1,M+1):
    count=0
    for j in range(N):
        if i in A[j][1:]:
            count+=1
        if count==N:
            ans+=1
print(ans) import numpy as np numpy N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M [int(i) for i in input().split()] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [int(i) for i in input().split()] A = [[int(i) for i in input().split()] for _ in range(N)] A [[int(i) for i in input().split()] for _ in range(N)] ans=0 ans 0 for i in range(1,M+1):
    count=0
    for j in range(N):
        if i in A[j][1:]:
            count+=1
        if count==N:
            ans+=1 i range(1,M+1) range 1 M+1 M 1 count=0 count 0 for j in range(N):
        if i in A[j][1:]:
            count+=1
        if count==N:
            ans+=1 j range(N) range N if i in A[j][1:]:
            count+=1
         i in A[j][1:] i A[j][1:] [j] A j 1: 1 count+=1 count 1 if count==N:
            ans+=1 count==N count N ans+=1 ans 1 print(ans) print ans A = [[int(i) for i in input().split()] for _ in range(N)] [[int(i) for i in input().split()] for _ in range(N)] A M = map(int,input().split()) map(int,input().split()) M N,M = map(int,input().split()) map(int,input().split()) N ans=0 0 ans count=0 0 count ans+=1 1 ans count+=1 1 count
import numpy as np
N,M = map(int,input().split())
A = [[int(i) for i in input().split()] for _ in range(N)]

ans=0
for i in range(1,M+1):
    count=0
    for j in range(N):
        if i in A[j][1:]:
            count+=1
        if count==N:
            ans+=1
print(ans)
