N, M = map(int, input().split())
P = [0 for i in range(M)]
for i in range(N):
  A = list(map(int, input().split()))
  for a in A[1:]:
    P[a-1] += 1
print(len([i for i in range(M) if P[i] == N])) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M 0 for i in range(M) for i in range(M) i range(M) range M for i in range(M) 0 P = [0 for i in range(M)] P [0 for i in range(M)] for i in range(N):
  A = list(map(int, input().split()))
  for a in A[1:]:
    P[a-1] += 1 i range(N) range N A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for a in A[1:]:
    P[a-1] += 1 a A[1:] A 1: 1 P[a-1] += 1 P[a-1] P a-1 a 1 1 i for i in range(M) if P[i] == N for i in range(M) if P[i] == N i range(M) range M P[i] == N P[i] P i N if P[i] == N i print(len([i for i in range(M) if P[i] == N])) print len([i for i in range(M) if P[i] == N]) len [i for i in range(M) if P[i] == N] P = [0 for i in range(M)] [0 for i in range(M)] P A = list(map(int, input().split())) list(map(int, input().split())) A N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
P = [0 for i in range(M)]
for i in range(N):
  A = list(map(int, input().split()))
  for a in A[1:]:
    P[a-1] += 1
print(len([i for i in range(M) if P[i] == N]))