n,m = map(int,input().split())

k_lst = []
a_lst = []
for _ in range(n):
    lst = list(map(int,input().split()))
    k_lst.append(lst[0])
    a_lst.append(lst[1:])

temp = a_lst[0]

for i in range(1,n):
    lstwa = temp + a_lst[i]
    tyofuku = [x for x in set(lstwa) if lstwa.count(x) > 1]
    temp = tyofuku

print(len(temp)) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m k_lst = [] k_lst [] a_lst = [] a_lst [] for _ in range(n):
    lst = list(map(int,input().split()))
    k_lst.append(lst[0])
    a_lst.append(lst[1:]) _ range(n) range n lst = list(map(int,input().split())) lst list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k_lst.append(lst[0]) k_lst.append k_lst append lst[0] lst 0 a_lst.append(lst[1:]) a_lst.append a_lst append lst[1:] lst 1: 1 temp = a_lst[0] temp a_lst[0] a_lst 0 for i in range(1,n):
    lstwa = temp + a_lst[i]
    tyofuku = [x for x in set(lstwa) if lstwa.count(x) > 1]
    temp = tyofuku i range(1,n) range 1 n lstwa = temp + a_lst[i] lstwa temp + a_lst[i] temp a_lst[i] a_lst i x for x in set(lstwa) if lstwa.count(x) > 1 for x in set(lstwa) if lstwa.count(x) > 1 x set(lstwa) set lstwa lstwa.count(x) > 1 lstwa.count(x) lstwa.count lstwa count x 1 if lstwa.count(x) > 1 x tyofuku = [x for x in set(lstwa) if lstwa.count(x) > 1] tyofuku [x for x in set(lstwa) if lstwa.count(x) > 1] temp = tyofuku temp tyofuku print(len(temp)) print len(temp) len temp temp = tyofuku tyofuku temp m = map(int,input().split()) map(int,input().split()) m lstwa = temp + a_lst[i] temp + a_lst[i] lstwa n,m = map(int,input().split()) map(int,input().split()) n a_lst = [] [] a_lst lst = list(map(int,input().split())) list(map(int,input().split())) lst k_lst = [] [] k_lst temp = a_lst[0] a_lst[0] temp tyofuku = [x for x in set(lstwa) if lstwa.count(x) > 1] [x for x in set(lstwa) if lstwa.count(x) > 1] tyofuku
n,m = map(int,input().split())

k_lst = []
a_lst = []
for _ in range(n):
    lst = list(map(int,input().split()))
    k_lst.append(lst[0])
    a_lst.append(lst[1:])

temp = a_lst[0]

for i in range(1,n):
    lstwa = temp + a_lst[i]
    tyofuku = [x for x in set(lstwa) if lstwa.count(x) > 1]
    temp = tyofuku

print(len(temp))