import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] favorite = new int[m];
		for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		}
		int answer = 0;
		for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		}

		System.out.println(answer);
	}

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

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] favorite = new int[m];
		for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		}
		int answer = 0;
		for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		}

		System.out.println(answer);
	}

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


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] favorite = new int[m];
		for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		}
		int answer = 0;
		for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		}

		System.out.println(answer);
	} main {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] favorite = new int[m];
		for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		}
		int answer = 0;
		for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		}

		System.out.println(answer);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] favorite = new int[m]; favorite new int[m] m for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		} {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		} int loopCount = sc.nextInt(); loopCount sc.nextInt() sc.nextInt sc for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			} int j = 0; int j = 0; j 0 j <loopCount j loopCount j++ j++ j {
				favorite[sc.nextInt() -1]++;
			} {
				favorite[sc.nextInt() -1]++;
			} favorite[sc.nextInt() -1]++ favorite[sc.nextInt() -1] favorite sc.nextInt() -1 sc.nextInt() sc.nextInt sc 1 int answer = 0; answer 0 for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		} int i =0; int i =0; i 0 i < m i m i++ i++ i {
			if(favorite[i] == n) {
				answer++;
			}
		} {
			if(favorite[i] == n) {
				answer++;
			}
		} if(favorite[i] == n) {
				answer++;
			} favorite[i] == n favorite[i] favorite i n {
				answer++;
			} answer++ answer System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] favorite = new int[m];
		for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		}
		int answer = 0;
		for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		}

		System.out.println(answer);
	}

} public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] favorite = new int[m];
		for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		}
		int answer = 0;
		for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		}

		System.out.println(answer);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] favorite = new int[m];
		for(int i = 0; i < n; i++) {
			int loopCount = sc.nextInt();
			for(int j = 0; j <loopCount; j++) {
				favorite[sc.nextInt() -1]++;
			}
		}
		int answer = 0;
		for(int i =0; i < m; i++) {
			if(favorite[i] == n) {
				answer++;
			}
		}

		System.out.println(answer);
	}

}