#

import sys
from copy import deepcopy
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    sukic=[0]*(M+1)
    for i in range(N):
        A=list(map(int,input().split()))
        for j in range(A[0]):
            sukic[A[j+1]]+=1
    print(sukic.count(N))
    
if __name__=="__main__":
    main() import sys sys from copy import deepcopy input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N,M=map(int,input().split())
    sukic=[0]*(M+1)
    for i in range(N):
        A=list(map(int,input().split()))
        for j in range(A[0]):
            sukic[A[j+1]]+=1
    print(sukic.count(N))
     main N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M sukic=[0]*(M+1) sukic [0]*(M+1) [0] 0 M+1 M 1 for i in range(N):
        A=list(map(int,input().split()))
        for j in range(A[0]):
            sukic[A[j+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 for j in range(A[0]):
            sukic[A[j+1]]+=1
     j range(A[0]) range A[0] A 0 sukic[A[j+1]]+=1 sukic[A[j+1]] sukic A[j+1] A j+1 j 1 1 print(sukic.count(N)) print sukic.count(N) sukic.count sukic count N if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def main():
    N,M=map(int,input().split())
    sukic=[0]*(M+1)
    for i in range(N):
        A=list(map(int,input().split()))
        for j in range(A[0]):
            sukic[A[j+1]]+=1
    print(sukic.count(N))
     def main():
    N,M=map(int,input().split())
    sukic=[0]*(M+1)
    for i in range(N):
        A=list(map(int,input().split()))
        for j in range(A[0]):
            sukic[A[j+1]]+=1
    print(sukic.count(N))
     main input=sys.stdin.readline sys.stdin.readline input
#

import sys
from copy import deepcopy
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    sukic=[0]*(M+1)
    for i in range(N):
        A=list(map(int,input().split()))
        for j in range(A[0]):
            sukic[A[j+1]]+=1
    print(sukic.count(N))
    
if __name__=="__main__":
    main()
