#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,m = map(int, input().split())
k = [list(map(int,input().split())) for i in range(n)]

ans = [0]*m

for i in range(n):
    for j in range(1, k[i][0]+1):
        #print(k[i][j] -1)
        ans[ k[i][j] -1] += 1

#print(ans)
print(ans.count(n))



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

#print(ans) i range(n) range n for j in range(1, k[i][0]+1):
        #print(k[i][j] -1)
        ans[ k[i][j] -1] += 1

#print(ans) j range(1, k[i][0]+1) range 1 k[i][0]+1 k[i][0] [i] k i 0 1 ans[ k[i][j] -1] += 1 ans[ k[i][j] -1] ans k[i][j] -1 k[i][j] [i] k i j 1 1 print(ans.count(n)) print ans.count(n) ans.count ans count n m = map(int, input().split()) map(int, input().split()) m n,m = map(int, input().split()) map(int, input().split()) n ans = [0]*m [0]*m ans k = [list(map(int,input().split())) for i in range(n)] [list(map(int,input().split())) for i in range(n)] k
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,m = map(int, input().split())
k = [list(map(int,input().split())) for i in range(n)]

ans = [0]*m

for i in range(n):
    for j in range(1, k[i][0]+1):
        #print(k[i][j] -1)
        ans[ k[i][j] -1] += 1

#print(ans)
print(ans.count(n))




