N,M = map(int,input().split())
like = [1]
for i in range(2,M+1):
  like.append(i)
for j in range(N):
  A = list(map(int,input().split()[1:]))
  for l in range(M):
    if l+1 in A:
      continue
    else:
      if l+1 in like:
        like.remove(l+1)
print(len(like)) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M like = [1] like [1] 1 for i in range(2,M+1):
  like.append(i) i range(2,M+1) range 2 M+1 M 1 like.append(i) like.append like append i for j in range(N):
  A = list(map(int,input().split()[1:]))
  for l in range(M):
    if l+1 in A:
      continue
    else:
      if l+1 in like:
        like.remove(l+1) j range(N) range N A = list(map(int,input().split()[1:])) A list(map(int,input().split()[1:])) list map(int,input().split()[1:]) map int input().split()[1:] ().split() ().split () input split 1: 1 for l in range(M):
    if l+1 in A:
      continue
    else:
      if l+1 in like:
        like.remove(l+1) l range(M) range M if l+1 in A:
      continue
    else:
      if l+1 in like:
        like.remove(l+1) l+1 in A l+1 l 1 A continue if l+1 in like:
        like.remove(l+1) l+1 in like l+1 l 1 like like.remove(l+1) like.remove like remove l+1 l 1 print(len(like)) print len(like) len like like = [1] [1] like A = list(map(int,input().split()[1:])) list(map(int,input().split()[1:])) A 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())
like = [1]
for i in range(2,M+1):
  like.append(i)
for j in range(N):
  A = list(map(int,input().split()[1:]))
  for l in range(M):
    if l+1 in A:
      continue
    else:
      if l+1 in like:
        like.remove(l+1)
print(len(like))