import sys

n,m=map(int,input().split())
ans=[0]*(m+1)
output=0

for i in range(n):
    k=list(map(int,input().split()))
    for j in range(1,len(k)):
        ans[k[j]]+=1

for i in ans:
    if i==n:
        output+=1

print(output) import sys sys n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ans=[0]*(m+1) ans [0]*(m+1) [0] 0 m+1 m 1 output=0 output 0 for i in range(n):
    k=list(map(int,input().split()))
    for j in range(1,len(k)):
        ans[k[j]]+=1 i range(n) range n k=list(map(int,input().split())) k list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in range(1,len(k)):
        ans[k[j]]+=1 j range(1,len(k)) range 1 len(k) len k ans[k[j]]+=1 ans[k[j]] ans k[j] k j 1 for i in ans:
    if i==n:
        output+=1 i ans if i==n:
        output+=1 i==n i n output+=1 output 1 print(output) print output ans=[0]*(m+1) [0]*(m+1) ans output=0 0 output m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n k=list(map(int,input().split())) list(map(int,input().split())) k output+=1 1 output
import sys

n,m=map(int,input().split())
ans=[0]*(m+1)
output=0

for i in range(n):
    k=list(map(int,input().split()))
    for j in range(1,len(k)):
        ans[k[j]]+=1

for i in ans:
    if i==n:
        output+=1

print(output)