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


#print(A)
def comp(lst1,lst2):
    ret = []
    for i in lst1:
        if i in lst2:
            ret.append(i)
    return ret
ret = list(map(int,input().split()))
ret = ret[1:]
#print(ret)
for i in range(1,N):
    lst = list(map(int,input().split()))
    ret = comp(ret,lst[1:])
    #print(ret)
print(len(ret)) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M def comp(lst1,lst2):
    ret = []
    for i in lst1:
        if i in lst2:
            ret.append(i)
    return ret comp ret = [] ret [] for i in lst1:
        if i in lst2:
            ret.append(i)
     i lst1 if i in lst2:
            ret.append(i)
     i in lst2 i lst2 ret.append(i) ret.append ret append i return ret ret lst1 lst1 lst2 lst2 ret = list(map(int,input().split())) ret list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ret = ret[1:] ret ret[1:] ret 1: 1 for i in range(1,N):
    lst = list(map(int,input().split()))
    ret = comp(ret,lst[1:])
    #print(ret) i range(1,N) range 1 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 ret = comp(ret,lst[1:]) ret comp(ret,lst[1:]) comp ret lst[1:] lst 1: 1 print(len(ret)) print len(ret) len ret N,M = map(int,input().split()) map(int,input().split()) N ret = list(map(int,input().split())) list(map(int,input().split())) ret lst = list(map(int,input().split())) list(map(int,input().split())) lst ret = ret[1:] ret[1:] ret ret = comp(ret,lst[1:]) comp(ret,lst[1:]) ret M = map(int,input().split()) map(int,input().split()) M def comp(lst1,lst2):
    ret = []
    for i in lst1:
        if i in lst2:
            ret.append(i)
    return ret def comp(lst1,lst2):
    ret = []
    for i in lst1:
        if i in lst2:
            ret.append(i)
    return ret comp
N,M = map(int,input().split())


#print(A)
def comp(lst1,lst2):
    ret = []
    for i in lst1:
        if i in lst2:
            ret.append(i)
    return ret
ret = list(map(int,input().split()))
ret = ret[1:]
#print(ret)
for i in range(1,N):
    lst = list(map(int,input().split()))
    ret = comp(ret,lst[1:])
    #print(ret)
print(len(ret))