N, M = map(int, input().split())
ans = set(range(1,M+1))
for i in range(N):
    A = set(map(int, input().split()[1:]))
    ans = ans&A
#    print(ans)
#    print(i)
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 i in range(N):
    A = set(map(int, input().split()[1:]))
    ans = ans&A
#    print(ans)
#    print(i) i range(N) range N A = set(map(int, input().split()[1:])) A set(map(int, input().split()[1:])) set map(int, input().split()[1:]) map int input().split()[1:] ().split() ().split () input split 1: 1 ans = ans&A ans ans&A ans A print(len(ans)) print len(ans) len ans ans = set(range(1,M+1)) set(range(1,M+1)) ans A = set(map(int, input().split()[1:])) set(map(int, input().split()[1:])) A N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M ans = ans&A ans&A ans
N, M = map(int, input().split())
ans = set(range(1,M+1))
for i in range(N):
    A = set(map(int, input().split()[1:]))
    ans = ans&A
#    print(ans)
#    print(i)
print(len(ans))
