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

foods =set([ i+1 for i in range(m)])


for _ in range(n):
    k = list(map(int,input().split()))
    fav = set(k[1:])

    foods = foods&fav

if len(foods)!=0:
    print(len(foods))
else:
    print(0) 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 foods =set([ i+1 for i in range(m)]) foods set([ i+1 for i in range(m)]) set [ i+1 for i in range(m)] for _ in range(n):
    k = list(map(int,input().split()))
    fav = set(k[1:])

    foods = foods&fav _ range(n) range n k = list(map(int,input().split())) k list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split fav = set(k[1:]) fav set(k[1:]) set k[1:] k 1: 1 foods = foods&fav foods foods&fav foods fav if len(foods)!=0:
    print(len(foods))
else:
    print(0) len(foods)!=0 len(foods) len foods 0 print(len(foods)) print len(foods) len foods print(0) print 0 fav = set(k[1:]) set(k[1:]) fav foods =set([ i+1 for i in range(m)]) set([ i+1 for i in range(m)]) foods k = list(map(int,input().split())) list(map(int,input().split())) k foods = foods&fav foods&fav foods n,m =map(int,input().split()) map(int,input().split()) n m =map(int,input().split()) map(int,input().split()) m
n,m =map(int,input().split())

foods =set([ i+1 for i in range(m)])


for _ in range(n):
    k = list(map(int,input().split()))
    fav = set(k[1:])

    foods = foods&fav

if len(foods)!=0:
    print(len(foods))
else:
    print(0)