n,m=map(int,input().split())
flg=[1]*m
for i in range(n):
  a=list(map(int,input().split()))[1:]
  for j in range(m):
    if j+1 not in a:
      flg[j]=0
print(sum(flg)) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m flg=[1]*m flg [1]*m [1] 1 m for i in range(n):
  a=list(map(int,input().split()))[1:]
  for j in range(m):
    if j+1 not in a:
      flg[j]=0 i range(n) range n a=list(map(int,input().split()))[1:] a list(map(int,input().split()))[1:] (map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 1: 1 for j in range(m):
    if j+1 not in a:
      flg[j]=0 j range(m) range m if j+1 not in a:
      flg[j]=0 j+1 not in a j+1 j 1 a flg[j]=0 flg[j] flg j 0 print(sum(flg)) print sum(flg) sum flg flg=[1]*m [1]*m flg n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m a=list(map(int,input().split()))[1:] list(map(int,input().split()))[1:] a
n,m=map(int,input().split())
flg=[1]*m
for i in range(n):
  a=list(map(int,input().split()))[1:]
  for j in range(m):
    if j+1 not in a:
      flg[j]=0
print(sum(flg))