import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()

d = defaultdict(int)

for _ in range(N):
    A = li()
    for i in range(1, len(A)):
        d[A[i]] += 1

ans = 0

for key, value in d.items():
    if value == N:
        ans += 1

print(ans) import sys sys sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 def ii(): return int(sys.stdin.readline()) ii def mi(): return map(int, sys.stdin.readline().split()) mi def li(): return list(map(int, sys.stdin.readline().split())) li list(map(int, sys.stdin.readline().split())) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] li2 N N [ini]*i for _ in range(j) for _ in range(j) _ range(j) range j for _ in range(j) [ini]*i [ini] ini i def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a) dp2 ini ini i i j j from collections import defaultdict N, M = mi() N mi() mi M d = defaultdict(int) d defaultdict(int) defaultdict int for _ in range(N):
    A = li()
    for i in range(1, len(A)):
        d[A[i]] += 1 _ range(N) range N A = li() A li() li for i in range(1, len(A)):
        d[A[i]] += 1 i range(1, len(A)) range 1 len(A) len A d[A[i]] += 1 d[A[i]] d A[i] A i 1 ans = 0 ans 0 for key, value in d.items():
    if value == N:
        ans += 1 key value d.items() d.items d items if value == N:
        ans += 1 value == N value N ans += 1 ans 1 print(ans) print ans N, M = mi() mi() N def li(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) li M = mi() mi() M def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] li2 def mi(): return map(int, sys.stdin.readline().split()) def mi(): return map(int, sys.stdin.readline().split()) mi def ii(): return int(sys.stdin.readline()) def ii(): return int(sys.stdin.readline()) ii def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a) def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a) dp2 d = defaultdict(int) defaultdict(int) d A = li() li() A ans += 1 1 ans ans = 0 0 ans
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()

d = defaultdict(int)

for _ in range(N):
    A = li()
    for i in range(1, len(A)):
        d[A[i]] += 1

ans = 0

for key, value in d.items():
    if value == N:
        ans += 1

print(ans)