N,M = map(int,input().split())
K = []
sum = 0
if N==1:
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
  print(len(K))
  exit()
for i in range(N):
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
for T in range(1,len(K)+1):
  B=K.count(T)
  if B == N:
    sum+=1
print(sum) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M K = [] K [] sum = 0 sum 0 if N==1:
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
  print(len(K))
  exit() N==1 N 1 W=list(map(int,input().split())) W list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split W.pop(0) W.pop W pop 0 K+=W K W print(len(K)) print len(K) len K exit() exit for i in range(N):
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W i range(N) range N W=list(map(int,input().split())) W list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split W.pop(0) W.pop W pop 0 K+=W K W for T in range(1,len(K)+1):
  B=K.count(T)
  if B == N:
    sum+=1 T range(1,len(K)+1) range 1 len(K)+1 len(K) len K 1 B=K.count(T) B K.count(T) K.count K count T if B == N:
    sum+=1 B == N B N sum+=1 sum 1 print(sum) print sum K+=W W K B=K.count(T) K.count(T) B sum+=1 1 sum K+=W W K W=list(map(int,input().split())) list(map(int,input().split())) W sum = 0 0 sum W=list(map(int,input().split())) list(map(int,input().split())) W N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M K = [] [] K
N,M = map(int,input().split())
K = []
sum = 0
if N==1:
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
  print(len(K))
  exit()
for i in range(N):
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
for T in range(1,len(K)+1):
  B=K.count(T)
  if B == N:
    sum+=1
print(sum)
