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