n , m = map(int, input().split())
e = 0
d = []
for i in range(1, n + 1):
  l = list(map(int, input().split()))
  for a in range(l[0]):
    b = l[a + 1]
    d.append(b)
for j in range(1, m + 1):
  c = 0
  for k in d:
    if k == j:
      c += 1
  if c == n:
    e += 1
print(e) n , m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m e = 0 e 0 d = [] d [] for i in range(1, n + 1):
  l = list(map(int, input().split()))
  for a in range(l[0]):
    b = l[a + 1]
    d.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]
    d.append(b) a range(l[0]) range l[0] l 0 b = l[a + 1] b l[a + 1] l a + 1 a 1 d.append(b) d.append d append b for j in range(1, m + 1):
  c = 0
  for k in d:
    if k == j:
      c += 1
  if c == n:
    e += 1 j range(1, m + 1) range 1 m + 1 m 1 c = 0 c 0 for k in d:
    if k == j:
      c += 1
   k d if k == j:
      c += 1
   k == j k j c += 1 c 1 if c == n:
    e += 1 c == n c n e += 1 e 1 print(e) print e l = list(map(int, input().split())) list(map(int, input().split())) l b = l[a + 1] l[a + 1] b c = 0 0 c c += 1 1 c d = [] [] d e = 0 0 e m = map(int, input().split()) map(int, input().split()) m e += 1 1 e n , m = map(int, input().split()) map(int, input().split()) n
n , m = map(int, input().split())
e = 0
d = []
for i in range(1, n + 1):
  l = list(map(int, input().split()))
  for a in range(l[0]):
    b = l[a + 1]
    d.append(b)
for j in range(1, m + 1):
  c = 0
  for k in d:
    if k == j:
      c += 1
  if c == n:
    e += 1
print(e)