import collections

N, M = map(int, input().split())
koubutu = []
for _ in range(N):
    ka = list(map(int, input().split()))
    koubutu.extend(ka[1:])
print(list(collections.Counter(koubutu).values()).count(N)) import collections collections N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M koubutu = [] koubutu [] for _ in range(N):
    ka = list(map(int, input().split()))
    koubutu.extend(ka[1:]) _ range(N) range N ka = list(map(int, input().split())) ka list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split koubutu.extend(ka[1:]) koubutu.extend koubutu extend ka[1:] ka 1: 1 print(list(collections.Counter(koubutu).values()).count(N)) print list(collections.Counter(koubutu).values()).count(N) (collections.Counter(koubutu).values()).count (collections.Counter(koubutu).values()) list collections.Counter(koubutu).values() collections.Counter(koubutu).values collections.Counter(koubutu) collections.Counter collections Counter koubutu values count N ka = list(map(int, input().split())) list(map(int, input().split())) ka koubutu = [] [] koubutu N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M
import collections

N, M = map(int, input().split())
koubutu = []
for _ in range(N):
    ka = list(map(int, input().split()))
    koubutu.extend(ka[1:])
print(list(collections.Counter(koubutu).values()).count(N))