import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n,m=inp()
l=[0]*m
for _ in range(n):
    a=linp()
    for i in range(1,a[0]+1):
        l[a[i]-1]+=1

ans=0
for x in l:
    if x==n:ans+=1
print(ans) import math math def ip():return int(input()) ip def inp():return map(int,input().split()) inp def inpstr():return map(str,input().split()) inpstr def linp():return list(map(int,input().split())) linp def linpstr():return list(map(str,input().split())) linpstr n,m=inp() n inp() inp m l=[0]*m l [0]*m [0] 0 m for _ in range(n):
    a=linp()
    for i in range(1,a[0]+1):
        l[a[i]-1]+=1 _ range(n) range n a=linp() a linp() linp for i in range(1,a[0]+1):
        l[a[i]-1]+=1 i range(1,a[0]+1) range 1 a[0]+1 a[0] a 0 1 l[a[i]-1]+=1 l[a[i]-1] l a[i]-1 a[i] a i 1 1 ans=0 ans 0 for x in l:
    if x==n:ans+=1 x l if x==n:an x==n x n print(ans) print ans def ip():return int(input()) def ip():return int(input()) ip def inpstr():return map(str,input().split()) def inpstr():return map(str,input().split()) inpstr def inp():return map(int,input().split()) def inp():return map(int,input().split()) inp m=inp() inp() m def linpstr():return list(map(str,input().split())) def linpstr():return list(map(str,input().split())) linpstr def linp():return list(map(int,input().split())) def linp():return list(map(int,input().split())) linp n,m=inp() inp() n a=linp() linp() a ans=0 0 ans l=[0]*m [0]*m l
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n,m=inp()
l=[0]*m
for _ in range(n):
    a=linp()
    for i in range(1,a[0]+1):
        l[a[i]-1]+=1

ans=0
for x in l:
    if x==n:ans+=1
print(ans)