N, M = map(int, input().split())
l = []
for i in range(N):
  l.append(list(map(int, input().split())))
  
ans = [0] * (M+1)
for i in range(N):
  n = l[i]
  for j in range(1, n[0]+1):
    ans[n[j]] += 1
    
cnt = 0
for i in range(M+1):
  if ans[i] == N:
    cnt += 1
print(cnt) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M l = [] l [] for i in range(N):
  l.append(list(map(int, input().split())))
   i range(N) range N l.append(list(map(int, input().split()))) l.append l append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = [0] * (M+1) ans [0] * (M+1) [0] 0 M+1 M 1 for i in range(N):
  n = l[i]
  for j in range(1, n[0]+1):
    ans[n[j]] += 1
     i range(N) range N n = l[i] n l[i] l i for j in range(1, n[0]+1):
    ans[n[j]] += 1
     j range(1, n[0]+1) range 1 n[0]+1 n[0] n 0 1 ans[n[j]] += 1 ans[n[j]] ans n[j] n j 1 cnt = 0 cnt 0 for i in range(M+1):
  if ans[i] == N:
    cnt += 1 i range(M+1) range M+1 M 1 if ans[i] == N:
    cnt += 1 ans[i] == N ans[i] ans i N cnt += 1 cnt 1 print(cnt) print cnt N, M = map(int, input().split()) map(int, input().split()) N l = [] [] l M = map(int, input().split()) map(int, input().split()) M cnt += 1 1 cnt n = l[i] l[i] n ans = [0] * (M+1) [0] * (M+1) ans cnt = 0 0 cnt
N, M = map(int, input().split())
l = []
for i in range(N):
  l.append(list(map(int, input().split())))
  
ans = [0] * (M+1)
for i in range(N):
  n = l[i]
  for j in range(1, n[0]+1):
    ans[n[j]] += 1
    
cnt = 0
for i in range(M+1):
  if ans[i] == N:
    cnt += 1
print(cnt)