#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
import collections as C

#N = int(input())
N,M= map(int,input().split())
#P = list(map(int,input().split()))

#S= str(input())
#prod = functools.partial(functools.reduce, operator.mul)
#c=np.array(A)
#p=np.prod(A)

num=[0 for x in range(31)]
for i in range(N):

    K = list(map(int,input().split()))
    for j in K[1:]:
        num[j]+=1
c=0
for k in num:
    if k==N:
        c+=1
print(c) import collections as C collections N,M= map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M 0 for x in range(31) for x in range(31) x range(31) range 31 for x in range(31) 0 num=[0 for x in range(31)] num [0 for x in range(31)] for i in range(N):

    K = list(map(int,input().split()))
    for j in K[1:]:
        num[j]+=1 i range(N) range N K = list(map(int,input().split())) K list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in K[1:]:
        num[j]+=1 j K[1:] K 1: 1 num[j]+=1 num[j] num j 1 c=0 c 0 for k in num:
    if k==N:
        c+=1 k num if k==N:
        c+=1 k==N k N c+=1 c 1 print(c) print c c=0 0 c N,M= map(int,input().split()) map(int,input().split()) N c+=1 1 c M= map(int,input().split()) map(int,input().split()) M K = list(map(int,input().split())) list(map(int,input().split())) K num=[0 for x in range(31)] [0 for x in range(31)] num
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
import collections as C

#N = int(input())
N,M= map(int,input().split())
#P = list(map(int,input().split()))

#S= str(input())
#prod = functools.partial(functools.reduce, operator.mul)
#c=np.array(A)
#p=np.prod(A)

num=[0 for x in range(31)]
for i in range(N):

    K = list(map(int,input().split()))
    for j in K[1:]:
        num[j]+=1
c=0
for k in num:
    if k==N:
        c+=1
print(c)
