n,m=map(int,input().split())
l = [0]*m
for i in range(n):
    a = list(map(int, input().split()))
    del a[0]
    for i in a:
        l[i-1] +=1
print(l.count(n)) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m l = [0]*m l [0]*m [0] 0 m for i in range(n):
    a = list(map(int, input().split()))
    del a[0]
    for i in a:
        l[i-1] +=1 i 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 del a[0] a[0] a 0 for i in a:
        l[i-1] +=1 i a l[i-1] +=1 l[i-1] l i-1 i 1 1 print(l.count(n)) print l.count(n) l.count l count n a = list(map(int, input().split())) list(map(int, input().split())) a m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n l = [0]*m [0]*m l
n,m=map(int,input().split())
l = [0]*m
for i in range(n):
    a = list(map(int, input().split()))
    del a[0]
    for i in a:
        l[i-1] +=1
print(l.count(n))