N , M = map(int,input().split())
con = 0
like = 0
List = []
for i in range(1,N+1):
  L = list(map(int,input().split()))
  for a in range(L[0]):
    b = L[a + 1]
    List.append(b)
for j in range(1,M + 1):
  con = 0
  for k in List:
    if k == j:
      con += 1
  if con == N:
    like += 1   
print(like) N , M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M con = 0 con 0 like = 0 like 0 List = [] List [] for i in range(1,N+1):
  L = list(map(int,input().split()))
  for a in range(L[0]):
    b = L[a + 1]
    List.append(b) i range(1,N+1) range 1 N+1 N 1 L = list(map(int,input().split())) L list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for a in range(L[0]):
    b = L[a + 1]
    List.append(b) a range(L[0]) range L[0] L 0 b = L[a + 1] b L[a + 1] L a + 1 a 1 List.append(b) List.append List append b for j in range(1,M + 1):
  con = 0
  for k in List:
    if k == j:
      con += 1
  if con == N:
    like += 1    j range(1,M + 1) range 1 M + 1 M 1 con = 0 con 0 for k in List:
    if k == j:
      con += 1
   k List if k == j:
      con += 1
   k == j k j con += 1 con 1 if con == N:
    like += 1    con == N con N like += 1 like 1 print(like) print like N , M = map(int,input().split()) map(int,input().split()) N List = [] [] List like = 0 0 like con = 0 0 con L = list(map(int,input().split())) list(map(int,input().split())) L like += 1 1 like b = L[a + 1] L[a + 1] b con = 0 0 con M = map(int,input().split()) map(int,input().split()) M con += 1 1 con
N , M = map(int,input().split())
con = 0
like = 0
List = []
for i in range(1,N+1):
  L = list(map(int,input().split()))
  for a in range(L[0]):
    b = L[a + 1]
    List.append(b)
for j in range(1,M + 1):
  con = 0
  for k in List:
    if k == j:
      con += 1
  if con == N:
    like += 1   
print(like)
