from functools import reduce

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

prod = set(range(1, M + 1))

for _ in range(N):

    prod &= set(list(map(int, input().split()))[1:])

ans = len(prod)

print(ans)
# 入力

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

K, A = list(zip(*(

    (int(t[0]), list(map(int, t[1].split())))

    for t in (input().split(maxsplit=1) for _ in range(N))

)))



# 素直にカウント

ans = sum(

    all(k in a for a in A)

    for k in range(1, M + 1)

)



# 出力

print(ans)

from functools import reduce

N, M = list(map(int, input().split()))
prod = set(range(1, M + 1))
for _ in range(N):
    prod &= set(list(map(int, input().split()))[1:])
ans = len(prod)
print(ans)

# 入力
N, M = list(map(int, input().split()))
K, A = list(
    zip(
        *(
            (int(t[0]), list(map(int, t[1].split())))
            for t in (input().split(maxsplit=1) for _ in range(N))
        )
    )
)
# 素直にカウント
ans = sum(all(k in a for a in A) for k in range(1, M + 1))
# 出力
print(ans)

-from functools import reduce - +# 入力 -prod = set(range(1, M + 1)) -for _ in range(N): -    prod &= set(list(map(int, input().split()))[1:]) -ans = len(prod) +K, A = list( +    zip( +        *( +            (int(t[0]), list(map(int, t[1].split()))) +            for t in (input().split(maxsplit=1) for _ in range(N)) +        ) +    ) +) +# 素直にカウント +ans = sum(all(k in a for a in A) for k in range(1, M + 1)) +# 出力