#!/usr/bin/env python3

N,M = map(int,input().split())
lst = [i+1 for i in range(M)]


for _ in range(N):
    tmp = list(map(int,input().split()))
    K = tmp[0]
    A = tmp[1:]
    lst = list(filter(lambda x: x in A,lst))

print(len(lst)) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M i+1 for i in range(M) for i in range(M) i range(M) range M for i in range(M) i+1 i 1 lst = [i+1 for i in range(M)] lst [i+1 for i in range(M)] for _ in range(N):
    tmp = list(map(int,input().split()))
    K = tmp[0]
    A = tmp[1:]
    lst = list(filter(lambda x: x in A,lst)) _ range(N) range N tmp = list(map(int,input().split())) tmp list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split K = tmp[0] K tmp[0] tmp 0 A = tmp[1:] A tmp[1:] tmp 1: 1 lst = list(filter(lambda x: x in A,lst)) lst list(filter(lambda x: x in A,lst)) list filter(lambda x: x in A,lst) filter lambda x: x in A x in A x A x lst print(len(lst)) print len(lst) len lst K = tmp[0] tmp[0] K N,M = map(int,input().split()) map(int,input().split()) N lst = [i+1 for i in range(M)] [i+1 for i in range(M)] lst lst = list(filter(lambda x: x in A,lst)) list(filter(lambda x: x in A,lst)) lst tmp = list(map(int,input().split())) list(map(int,input().split())) tmp M = map(int,input().split()) map(int,input().split()) M A = tmp[1:] tmp[1:] A
#!/usr/bin/env python3

N,M = map(int,input().split())
lst = [i+1 for i in range(M)]


for _ in range(N):
    tmp = list(map(int,input().split()))
    K = tmp[0]
    A = tmp[1:]
    lst = list(filter(lambda x: x in A,lst))

print(len(lst))