import sys
import collections
import itertools

N,M = map(int,input().split())
array_2 = []
for I in range(N):
    array_2.append(input().split())
for I in array_2:
    del I[0]

array_2 = itertools.chain.from_iterable(array_2)
array_2 = collections.Counter(array_2)
count = 0
for I in array_2:
    if array_2[I] == N: count += 1
print(count)     import sys sys import collections collections import itertools itertools N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M array_2 = [] array_2 [] for I in range(N):
    array_2.append(input().split()) I range(N) range N array_2.append(input().split()) array_2.append array_2 append input().split() ().split () input split for I in array_2:
    del I[0] I array_2 del I[0] I[0] I 0 array_2 = itertools.chain.from_iterable(array_2) array_2 itertools.chain.from_iterable(array_2) itertools.chain.from_iterable itertools.chain itertools chain from_iterable array_2 array_2 = collections.Counter(array_2) array_2 collections.Counter(array_2) collections.Counter collections Counter array_2 count = 0 count 0 for I in array_2:
    if array_2[I] == N: count += 1 I array_2 if array_2[I] == N: count  array_2[I] == N array_2[I] array_2 I N print(count) print count M = map(int,input().split()) map(int,input().split()) M N,M = map(int,input().split()) map(int,input().split()) N array_2 = itertools.chain.from_iterable(array_2) itertools.chain.from_iterable(array_2) array_2 array_2 = [] [] array_2 count = 0 0 count array_2 = collections.Counter(array_2) collections.Counter(array_2) array_2
import sys
import collections
import itertools

N,M = map(int,input().split())
array_2 = []
for I in range(N):
    array_2.append(input().split())
for I in array_2:
    del I[0]

array_2 = itertools.chain.from_iterable(array_2)
array_2 = collections.Counter(array_2)
count = 0
for I in array_2:
    if array_2[I] == N: count += 1
print(count)    