read n k

for i in `seq "$k"`
do
	read "d_$i"
    read -a "a${i}s"
done

result=(`seq "$n"`)

for i in `seq "$k"`
do
	temp=a${i}s[@]
    
	# ${result[@]} \= ${!temp}
    for j in "${!temp}"
    do
    	for k in "${!result[@]}"
        do
        	if [[ "${result[k]}" = "$j" ]]; then
            	unset result[k]
            fi
        done
    done
done

echo "${#result[@]}"