n, m = map(int, input().split())

l = [0] * (m+1)
for i in range(n):
  inp = list(map(int, input().split()))
  for j in range(1, inp[0]+1):
    l[inp[j]] += 1
ans = 0
#print(l, n)
for i in range(1, m+1):
  if l[i] == n:
    ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l = [0] * (m+1) l [0] * (m+1) [0] 0 m+1 m 1 for i in range(n):
  inp = list(map(int, input().split()))
  for j in range(1, inp[0]+1):
    l[inp[j]] += 1 i range(n) range n inp = list(map(int, input().split())) inp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for j in range(1, inp[0]+1):
    l[inp[j]] += 1 j range(1, inp[0]+1) range 1 inp[0]+1 inp[0] inp 0 1 l[inp[j]] += 1 l[inp[j]] l inp[j] inp j 1 ans = 0 ans 0 for i in range(1, m+1):
  if l[i] == n:
    ans += 1 i range(1, m+1) range 1 m+1 m 1 if l[i] == n:
    ans += 1 l[i] == n l[i] l i n ans += 1 ans 1 print(ans) print ans n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m ans += 1 1 ans l = [0] * (m+1) [0] * (m+1) l inp = list(map(int, input().split())) list(map(int, input().split())) inp ans = 0 0 ans
n, m = map(int, input().split())

l = [0] * (m+1)
for i in range(n):
  inp = list(map(int, input().split()))
  for j in range(1, inp[0]+1):
    l[inp[j]] += 1
ans = 0
#print(l, n)
for i in range(1, m+1):
  if l[i] == n:
    ans += 1
print(ans)