n, m = map(int, input().split())
like = [0] * m
for i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    a = ka[1:]
    for j in a:
        like[j-1]+=1

print(like.count(n)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m like = [0] * m like [0] * m [0] 0 m for i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    a = ka[1:]
    for j in a:
        like[j-1]+=1 i range(n) range n ka = list(map(int, input().split())) ka list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k = ka[0] k ka[0] ka 0 a = ka[1:] a ka[1:] ka 1: 1 for j in a:
        like[j-1]+=1 j a like[j-1]+=1 like[j-1] like j-1 j 1 1 print(like.count(n)) print like.count(n) like.count like count n k = ka[0] ka[0] k m = map(int, input().split()) map(int, input().split()) m a = ka[1:] ka[1:] a n, m = map(int, input().split()) map(int, input().split()) n ka = list(map(int, input().split())) list(map(int, input().split())) ka like = [0] * m [0] * m like
n, m = map(int, input().split())
like = [0] * m
for i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    a = ka[1:]
    for j in a:
        like[j-1]+=1

print(like.count(n))