n,m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
  A[i].pop(0)
 
ans = 0
for j in range(1,m+1):
  if all(j in A[i] for i in range(len(A))) == True:
    ans += 1
 
print(ans) 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 A = [list(map(int, input().split())) for i in range(n)] A [list(map(int, input().split())) for i in range(n)] for i in range(n):
  A[i].pop(0)
  i range(n) range n A[i].pop(0) [i].pop [i] A i pop 0 ans = 0 ans 0 for j in range(1,m+1):
  if all(j in A[i] for i in range(len(A))) == True:
    ans += 1
  j range(1,m+1) range 1 m+1 m 1 if all(j in A[i] for i in range(len(A))) == True:
    ans += 1
  all(j in A[i] for i in range(len(A))) == True all(j in A[i] for i in range(len(A))) all j in A[i] j A[i] A i True ans += 1 ans 1 print(ans) print ans m = map(int, input().split()) map(int, input().split()) m n,m = map(int, input().split()) map(int, input().split()) n ans = 0 0 ans ans += 1 1 ans A = [list(map(int, input().split())) for i in range(n)] [list(map(int, input().split())) for i in range(n)] A
n,m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
  A[i].pop(0)
 
ans = 0
for j in range(1,m+1):
  if all(j in A[i] for i in range(len(A))) == True:
    ans += 1
 
print(ans)