N, M = map(int, input().split())

ans = [0 for i in range(M)]
for i in range(N):
    KM = list(map(int, input().split()))
    for j in range(1, len(KM)):
        ans[KM[j]-1] += 1

count = 0
for i in range(M):
    if ans[i] == N:
        count += 1
        
print(count) 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 ans = [0 for i in range(M)] ans [0 for i in range(M)] for i in range(N):
    KM = list(map(int, input().split()))
    for j in range(1, len(KM)):
        ans[KM[j]-1] += 1 i range(N) range N KM = list(map(int, input().split())) KM list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for j in range(1, len(KM)):
        ans[KM[j]-1] += 1 j range(1, len(KM)) range 1 len(KM) len KM ans[KM[j]-1] += 1 ans[KM[j]-1] ans KM[j]-1 KM[j] KM j 1 1 count = 0 count 0 for i in range(M):
    if ans[i] == N:
        count += 1
         i range(M) range M if ans[i] == N:
        count += 1
         ans[i] == N ans[i] ans i N count += 1 count 1 print(count) print count count += 1 1 count count = 0 0 count KM = list(map(int, input().split())) list(map(int, input().split())) KM N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M ans = [0 for i in range(M)] [0 for i in range(M)] ans
N, M = map(int, input().split())

ans = [0 for i in range(M)]
for i in range(N):
    KM = list(map(int, input().split()))
    for j in range(1, len(KM)):
        ans[KM[j]-1] += 1

count = 0
for i in range(M):
    if ans[i] == N:
        count += 1
        
print(count)