import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()

    X = [0]*(M+1)
    for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
    ans = 0
    for x in X:
        if x == N:
            ans += 1
    
    print(ans)
            
        



if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def mi(): return map(int,input().split()) mi def ii(): return int(input()) ii def isp(): return input().split() isp def deb(text): print("-------\n{}\n-------".format(text)) deb text text INF=10**20 INF 10**20 10 20 def main():
    N,M=mi()

    X = [0]*(M+1)
    for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
    ans = 0
    for x in X:
        if x == N:
            ans += 1
    
    print(ans)
            
         main N,M=mi() N mi() mi M X = [0]*(M+1) X [0]*(M+1) [0] 0 M+1 M 1 for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
     i range(N) range N Y = list(mi()) Y list(mi()) list mi() mi for a in Y[1:]:
            X[a] += 1
    
     a Y[1:] Y 1: 1 X[a] += 1 X[a] X a 1 ans = 0 ans 0 for x in X:
        if x == N:
            ans += 1
    
     x X if x == N:
            ans += 1
    
     x == N x N ans += 1 ans 1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def ii(): return int(input()) def ii(): return int(input()) ii INF=10**20 10**20 INF def isp(): return input().split() def isp(): return input().split() isp def deb(text): print("-------\n{}\n-------".format(text)) def deb(text): print("-------\n{}\n-------".format(text)) deb def mi(): return map(int,input().split()) def mi(): return map(int,input().split()) mi def main():
    N,M=mi()

    X = [0]*(M+1)
    for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
    ans = 0
    for x in X:
        if x == N:
            ans += 1
    
    print(ans)
            
         def main():
    N,M=mi()

    X = [0]*(M+1)
    for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
    ans = 0
    for x in X:
        if x == N:
            ans += 1
    
    print(ans)
            
         main
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()

    X = [0]*(M+1)
    for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
    ans = 0
    for x in X:
        if x == N:
            ans += 1
    
    print(ans)
            
        



if __name__ == "__main__":
    main()