from collections import Counter
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for _ in range(n)]

foods = [0]*m
for i in ka:
    for j in i[1:]:
        foods[j-1] += 1

foods = Counter(foods)
print(foods[n]) from collections import Counter n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ka = [list(map(int, input().split())) for _ in range(n)] ka [list(map(int, input().split())) for _ in range(n)] foods = [0]*m foods [0]*m [0] 0 m for i in ka:
    for j in i[1:]:
        foods[j-1] += 1 i ka for j in i[1:]:
        foods[j-1] += 1 j i[1:] i 1: 1 foods[j-1] += 1 foods[j-1] foods j-1 j 1 1 foods = Counter(foods) foods Counter(foods) Counter foods print(foods[n]) print foods[n] foods n n, m = map(int, input().split()) map(int, input().split()) n foods = Counter(foods) Counter(foods) foods m = map(int, input().split()) map(int, input().split()) m ka = [list(map(int, input().split())) for _ in range(n)] [list(map(int, input().split())) for _ in range(n)] ka foods = [0]*m [0]*m foods
from collections import Counter
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for _ in range(n)]

foods = [0]*m
for i in ka:
    for j in i[1:]:
        foods[j-1] += 1

foods = Counter(foods)
print(foods[n])
