import collections
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
result=[]
for i in range(a):
    n=c[i][1:]
    result+=n
ans=collections.Counter(result)
ans1,ans2=zip(*ans.most_common())
ans2=list(ans2)
print(ans2.count(a)) import collections collections a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b list(map(int,input().split())) for i in range(a) for i in range(a) i range(a) range a for i in range(a) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split c=[list(map(int,input().split())) for i in range(a)] c [list(map(int,input().split())) for i in range(a)] result=[] result [] for i in range(a):
    n=c[i][1:]
    result+=n i range(a) range a n=c[i][1:] n c[i][1:] [i] c i 1: 1 result+=n result n ans=collections.Counter(result) ans collections.Counter(result) collections.Counter collections Counter result ans1,ans2=zip(*ans.most_common()) ans1 zip(*ans.most_common()) zip *ans.most_common() ans.most_common() ans.most_common ans most_common ans2 ans2=list(ans2) ans2 list(ans2) list ans2 print(ans2.count(a)) print ans2.count(a) ans2.count ans2 count a result=[] [] result result+=n n result ans=collections.Counter(result) collections.Counter(result) ans ans1,ans2=zip(*ans.most_common()) zip(*ans.most_common()) ans1 ans2=zip(*ans.most_common()) zip(*ans.most_common()) ans2 n=c[i][1:] c[i][1:] n a,b=map(int,input().split()) map(int,input().split()) a b=map(int,input().split()) map(int,input().split()) b ans2=list(ans2) list(ans2) ans2 c=[list(map(int,input().split())) for i in range(a)] [list(map(int,input().split())) for i in range(a)] c
import collections
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
result=[]
for i in range(a):
    n=c[i][1:]
    result+=n
ans=collections.Counter(result)
ans1,ans2=zip(*ans.most_common())
ans2=list(ans2)
print(ans2.count(a))