n,m=map(int,input().split())
s=set(i+1 for i in range(m))

for i in range(n):
    t=[int(i) for i in input().split()]
    t=set(t[1:])
    s=s&t
print(len(s)) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m s=set(i+1 for i in range(m)) s set(i+1 for i in range(m)) set i+1 i 1 for i in range(n):
    t=[int(i) for i in input().split()]
    t=set(t[1:])
    s=s&t i range(n) range n int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i t=[int(i) for i in input().split()] t [int(i) for i in input().split()] t=set(t[1:]) t set(t[1:]) set t[1:] t 1: 1 s=s&t s s&t s t print(len(s)) print len(s) len s t=[int(i) for i in input().split()] [int(i) for i in input().split()] t s=set(i+1 for i in range(m)) set(i+1 for i in range(m)) s m=map(int,input().split()) map(int,input().split()) m n,m=map(int,input().split()) map(int,input().split()) n t=set(t[1:]) set(t[1:]) t s=s&t s&t s
n,m=map(int,input().split())
s=set(i+1 for i in range(m))

for i in range(n):
    t=[int(i) for i in input().split()]
    t=set(t[1:])
    s=s&t
print(len(s))