import numpy as np

N, M = list(map(int, input().split()))

menu = np.array([])

for i in range(N):

  a = np.array(input().split())

  menu = np.append(menu, a[1:])

menu = np.array(menu).astype(int).ravel()

count = 0

for i in range(1, M+1):

  if np.sum(menu == i) == N:

    count += 1

print(count)
# coding: utf-8

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

ll = [0] * m

for i in range(n):

    l = list(map(int, input().split()))

    for j in range(l[0]):

        ll[l[j+1] - 1] += 1

print((ll.count(max(ll)) if max(ll)==n else 0))
import numpy as np

N, M = list(map(int, input().split()))
menu = np.array([])
for i in range(N):
    a = np.array(input().split())
    menu = np.append(menu, a[1:])
menu = np.array(menu).astype(int).ravel()
count = 0
for i in range(1, M + 1):
    if np.sum(menu == i) == N:
        count += 1
print(count)

# coding: utf-8
n, m = list(map(int, input().split()))
ll = [0] * m
for i in range(n):
    l = list(map(int, input().split()))
    for j in range(l[0]):
        ll[l[j + 1] - 1] += 1
print((ll.count(max(ll)) if max(ll) == n else 0))

-import numpy as np - -N, M = list(map(int, input().split())) -menu = np.array([]) -for i in range(N): -    a = np.array(input().split()) -    menu = np.append(menu, a[1:]) -menu = np.array(menu).astype(int).ravel() -count = 0 -for i in range(1, M + 1): -    if np.sum(menu == i) == N: -        count += 1 -print(count) +# coding: utf-8 +n, m = list(map(int, input().split())) +ll = [0] * m +for i in range(n): +    l = list(map(int, input().split())) +    for j in range(l[0]): +        ll[l[j + 1] - 1] += 1 +print((ll.count(max(ll)) if max(ll) == n else 0))