from collections import defaultdict
N, M = map(int, input().split())
dict = defaultdict(int)
for _ in range(N):
    line = list(map(int, input().split()))
    K = line[0]
    A = line[1:]
    for a in A:
        dict[a] += 1
ans = 0
for k, v in dict.items():
    if v == N:
        ans += 1
print(ans) from collections import defaultdict N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M dict = defaultdict(int) dict defaultdict(int) defaultdict int for _ in range(N):
    line = list(map(int, input().split()))
    K = line[0]
    A = line[1:]
    for a in A:
        dict[a] += 1 _ range(N) range N line = list(map(int, input().split())) line list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K = line[0] K line[0] line 0 A = line[1:] A line[1:] line 1: 1 for a in A:
        dict[a] += 1 a A dict[a] += 1 dict[a] dict a 1 ans = 0 ans 0 for k, v in dict.items():
    if v == N:
        ans += 1 k v dict.items() dict.items dict items if v == N:
        ans += 1 v == N v N ans += 1 ans 1 print(ans) print ans N, M = map(int, input().split()) map(int, input().split()) N ans += 1 1 ans M = map(int, input().split()) map(int, input().split()) M K = line[0] line[0] K ans = 0 0 ans dict = defaultdict(int) defaultdict(int) dict A = line[1:] line[1:] A line = list(map(int, input().split())) list(map(int, input().split())) line
from collections import defaultdict
N, M = map(int, input().split())
dict = defaultdict(int)
for _ in range(N):
    line = list(map(int, input().split()))
    K = line[0]
    A = line[1:]
    for a in A:
        dict[a] += 1
ans = 0
for k, v in dict.items():
    if v == N:
        ans += 1
print(ans)
