if __name__ == '__main__':
    n, m = map(int, input().split())
    likeList =[0]*m
    for i in range(n):
        a = [int(i) for i in input().split()]
        for j in range(1,a[0]+1):
            likeList[a[j]-1]+=1


    count =0
    for i in likeList:
        if n == i:
            count+=1
    print(count) if __name__ == '__main__':
    n, m = map(int, input().split())
    likeList =[0]*m
    for i in range(n):
        a = [int(i) for i in input().split()]
        for j in range(1,a[0]+1):
            likeList[a[j]-1]+=1


    count =0
    for i in likeList:
        if n == i:
            count+=1
    print(count) __name__ == '__main__' __name__ '__main__' n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m likeList =[0]*m likeList [0]*m [0] 0 m for i in range(n):
        a = [int(i) for i in input().split()]
        for j in range(1,a[0]+1):
            likeList[a[j]-1]+=1


     i range(n) range n int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a = [int(i) for i in input().split()] a [int(i) for i in input().split()] for j in range(1,a[0]+1):
            likeList[a[j]-1]+=1


     j range(1,a[0]+1) range 1 a[0]+1 a[0] a 0 1 likeList[a[j]-1]+=1 likeList[a[j]-1] likeList a[j]-1 a[j] a j 1 1 count =0 count 0 for i in likeList:
        if n == i:
            count+=1
     i likeList if n == i:
            count+=1
     n == i n i count+=1 count 1 print(count) print count m = map(int, input().split()) map(int, input().split()) m a = [int(i) for i in input().split()] [int(i) for i in input().split()] a count =0 0 count count+=1 1 count n, m = map(int, input().split()) map(int, input().split()) n likeList =[0]*m [0]*m likeList
if __name__ == '__main__':
    n, m = map(int, input().split())
    likeList =[0]*m
    for i in range(n):
        a = [int(i) for i in input().split()]
        for j in range(1,a[0]+1):
            likeList[a[j]-1]+=1


    count =0
    for i in likeList:
        if n == i:
            count+=1
    print(count)