	import java.math.BigDecimal;
	import java.util.ArrayList;
	import java.util.Collections;
	import java.util.Comparator;
	import java.util.HashMap;
	import java.util.List;
	import java.util.Scanner;
	import java.util.regex.Matcher;
	import java.util.regex.Pattern;
	
	
	public class Main {
		static Scanner sc = new Scanner(System.in);
	
		public static void main (String [] args){
			//		String [][] boad = new String[4][4];
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			List <Integer> list = new ArrayList<Integer>();
			int total = 0;
	        HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
			for(int i = 0;i<n;i++){
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			}
			
			for(int j = 1;j<=m;j++){
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			}
			System.out.println(total);
			System.out.flush();
			sc.close();
		}
	} import java.math.BigDecimal; BigDecimal java.math import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util import java.util.HashMap; HashMap java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main {
		static Scanner sc = new Scanner(System.in);
	
		public static void main (String [] args){
			//		String [][] boad = new String[4][4];
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			List <Integer> list = new ArrayList<Integer>();
			int total = 0;
	        HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
			for(int i = 0;i<n;i++){
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			}
			
			for(int j = 1;j<=m;j++){
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			}
			System.out.println(total);
			System.out.flush();
			sc.close();
		}
	} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main (String [] args){
			//		String [][] boad = new String[4][4];
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			List <Integer> list = new ArrayList<Integer>();
			int total = 0;
	        HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
			for(int i = 0;i<n;i++){
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			}
			
			for(int j = 1;j<=m;j++){
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			}
			System.out.println(total);
			System.out.flush();
			sc.close();
		} main {
			//		String [][] boad = new String[4][4];
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			List <Integer> list = new ArrayList<Integer>();
			int total = 0;
	        HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
			for(int i = 0;i<n;i++){
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			}
			
			for(int j = 1;j<=m;j++){
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			}
			System.out.println(total);
			System.out.flush();
			sc.close();
		} int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc List <Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() int total = 0; total 0 HashMap<Integer, Integer> count = new HashMap<Integer, Integer>(); count new HashMap<Integer, Integer>() for(int i = 0;i<n;i++){
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			} int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			} {
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			} int s = Integer.parseInt(sc.next()); s Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				} int j = 0; int j = 0; j 0 j<s j s j++ j++ j {
					list.add(Integer.parseInt(sc.next()));
				} {
					list.add(Integer.parseInt(sc.next()));
				} list.add(Integer.parseInt(sc.next())) list.add list Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int j = 1;j<=m;j++){
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			} int j = 1; int j = 1; j 1 j<=m j m j++ j++ j {
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			} {
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			} int c = 0; c 0 for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				} int k = 0; int k = 0; k 0 k<list.size() k list.size() list.size list k++ k++ k {
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				} {
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				} if(j == list.get(k)){
						count.put(j,c+=1);
					} j == list.get(k) j list.get(k) list.get list k {
						count.put(j,c+=1);
					} count.put(j,c+=1) count.put count j c+=1 c 1 if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				} count.get(j)!=null && count.get(j)>=n count.get(j)!=null count.get(j) count.get count j null count.get(j)>=n count.get(j) count.get count j n {
					total += 1;
				} total += 1 total 1 System.out.println(total) System.out.println System.out System System.out total System.out.flush() System.out.flush System.out System System.out sc.close() sc.close sc String [] args args public class Main {
		static Scanner sc = new Scanner(System.in);
	
		public static void main (String [] args){
			//		String [][] boad = new String[4][4];
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			List <Integer> list = new ArrayList<Integer>();
			int total = 0;
	        HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
			for(int i = 0;i<n;i++){
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			}
			
			for(int j = 1;j<=m;j++){
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			}
			System.out.println(total);
			System.out.flush();
			sc.close();
		}
	} public class Main {
		static Scanner sc = new Scanner(System.in);
	
		public static void main (String [] args){
			//		String [][] boad = new String[4][4];
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			List <Integer> list = new ArrayList<Integer>();
			int total = 0;
	        HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
			for(int i = 0;i<n;i++){
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			}
			
			for(int j = 1;j<=m;j++){
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			}
			System.out.println(total);
			System.out.flush();
			sc.close();
		}
	} Main
	import java.math.BigDecimal;
	import java.util.ArrayList;
	import java.util.Collections;
	import java.util.Comparator;
	import java.util.HashMap;
	import java.util.List;
	import java.util.Scanner;
	import java.util.regex.Matcher;
	import java.util.regex.Pattern;
	
	
	public class Main {
		static Scanner sc = new Scanner(System.in);
	
		public static void main (String [] args){
			//		String [][] boad = new String[4][4];
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			List <Integer> list = new ArrayList<Integer>();
			int total = 0;
	        HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
			for(int i = 0;i<n;i++){
				int s = Integer.parseInt(sc.next()); 
				for(int j = 0;j<s;j++){
					list.add(Integer.parseInt(sc.next()));
				}
			}
			
			for(int j = 1;j<=m;j++){
				int c = 0;
				for(int k = 0;k<list.size();k++){
					if(j == list.get(k)){
						count.put(j,c+=1);
					}
				}
				if(count.get(j)!=null && count.get(j)>=n){
					total += 1;
				}
			}
			System.out.println(total);
			System.out.flush();
			sc.close();
		}
	}