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

ans = set(range(1, M+1))

for _ in range(N):
    L = list(map(int, input().split()))
    ans &= set(L[1:])

print(len(ans)) N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M ans = set(range(1, M+1)) ans set(range(1, M+1)) set range(1, M+1) range 1 M+1 M 1 for _ in range(N):
    L = list(map(int, input().split()))
    ans &= set(L[1:]) _ range(N) range N L = list(map(int, input().split())) L list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans &= set(L[1:]) ans set(L[1:]) set L[1:] L 1: 1 print(len(ans)) print len(ans) len ans N,M = map(int, input().split()) map(int, input().split()) N L = list(map(int, input().split())) list(map(int, input().split())) L M = map(int, input().split()) map(int, input().split()) M ans &= set(L[1:]) set(L[1:]) ans ans = set(range(1, M+1)) set(range(1, M+1)) ans
N,M = map(int, input().split())

ans = set(range(1, M+1))

for _ in range(N):
    L = list(map(int, input().split()))
    ans &= set(L[1:])

print(len(ans))