import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
} Main public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} catch (Exception e) {
			e.printStackTrace();
		}

	} main {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} catch (Exception e) {
			e.printStackTrace();
		}

	} String line = null; line null try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} catch (Exception e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} Exception e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) line = sc.nextLine() line sc.nextLine() sc.nextLine sc String[] tmpArray = line.split(" "); tmpArray line.split(" ") line.split line " " int numA = Integer.parseInt(tmpArray[0]); numA Integer.parseInt(tmpArray[0]) Integer.parseInt Integer tmpArray[0] tmpArray 0 int numB = Integer.parseInt(tmpArray[1]); numB Integer.parseInt(tmpArray[1]) Integer.parseInt Integer tmpArray[1] tmpArray 1 int[] tmpList = new int[numB]; tmpList new int[numB] numB int tmpInd = 0; tmpInd 0 for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				} int i = 0; int i = 0; i 0 i < numA i numA i++ i++ i {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				} {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				} line = sc.nextLine() line sc.nextLine() sc.nextLine sc String[] tmp = line.split(" "); tmp line.split(" ") line.split line " " for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				} int j = 0; int j = 0; j 0 j < tmp.length j tmp.length tmp tmp.length j++ j++ j {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				} {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				} if (j==0) continue; j==0 j 0 continue; tmpInd = Integer.parseInt(tmp[j]) tmpInd Integer.parseInt(tmp[j]) Integer.parseInt Integer tmp[j] tmp j tmpList[tmpInd-1] ++ tmpList[tmpInd-1] tmpList tmpInd-1 tmpInd 1 int reult = 0; reult 0 for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			} int k tmpList {
				if(k == numA){
					reult ++;
				}
			} {
				if(k == numA){
					reult ++;
				}
			} if(k == numA){
					reult ++;
				} k == numA k numA {
					reult ++;
				} reult ++ reult System.out.println(reult) System.out.println System.out System System.out reult String[] args args public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
} public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			String[] tmpArray = line.split(" ");
			int numA = Integer.parseInt(tmpArray[0]);
			int numB = Integer.parseInt(tmpArray[1]);

			
			int[] tmpList = new int[numB];
			int tmpInd = 0;
			for (int i = 0; i < numA; i++) {
				line = sc.nextLine();
				String[] tmp = line.split(" ");
				for (int j = 0; j < tmp.length; j++) {
					if (j==0) continue;
					tmpInd = Integer.parseInt(tmp[j]);
					tmpList[tmpInd-1] ++;
				}
				}
			int reult = 0;
			for(int k : tmpList){
				if(k == numA){
					reult ++;
				}
			}
				
			System.out.println(reult);
		
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}