import collections
n, m = map(int, raw_input().split(' '))
cc = collections.Counter()
for _ in range(n):
	for a in map(int, raw_input().split(' '))[1:]: cc[a] += 1
count = 0
for k in cc:
  	if cc[k] == n: count +=1
print count import collections collections n, m = map(int, raw_input().split(' ')) n map(int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' m cc = collections.Counter() cc collections.Counter() collections.Counter collections Counter for _ in range(n):
	for a in map(int, raw_input().split(' '))[1:]: cc[a] += 1 _ range(n) range n for a in map(int, raw_input().split(' '))[1:]: cc[a] +=  a map(int, raw_input().split(' '))[1:] (int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' 1: 1 count = 0 count 0 for k in cc:
  	if cc[k] == n: count +=1 k cc if cc[k] == n: count  cc[k] == n cc[k] cc k n print count = 0 0 count n, m = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) n cc = collections.Counter() collections.Counter() cc m = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) m
import collections
n, m = map(int, raw_input().split(' '))
cc = collections.Counter()
for _ in range(n):
	for a in map(int, raw_input().split(' '))[1:]: cc[a] += 1
count = 0
for k in cc:
  	if cc[k] == n: count +=1
print count