import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] k = new int[n][m];
		//input
		for(int i = 0; i < k.length; i++){
			int tmp = sc.nextInt();
			for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			}
		}
		int outp=0;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			}
		}
		System.out.println(outp);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] k = new int[n][m];
		//input
		for(int i = 0; i < k.length; i++){
			int tmp = sc.nextInt();
			for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			}
		}
		int outp=0;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			}
		}
		System.out.println(outp);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] k = new int[n][m];
		//input
		for(int i = 0; i < k.length; i++){
			int tmp = sc.nextInt();
			for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			}
		}
		int outp=0;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			}
		}
		System.out.println(outp);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] k = new int[n][m];
		//input
		for(int i = 0; i < k.length; i++){
			int tmp = sc.nextInt();
			for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			}
		}
		int outp=0;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			}
		}
		System.out.println(outp);
	} 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[][] k = new int[n][m]; k new int[n][m] n m for(int i = 0; i < k.length; i++){
			int tmp = sc.nextInt();
			for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			}
		} int i = 0; int i = 0; i 0 i < k.length i k.length k k.length i++ i++ i {
			int tmp = sc.nextInt();
			for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			}
		} {
			int tmp = sc.nextInt();
			for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			}
		} int tmp = sc.nextInt(); tmp sc.nextInt() sc.nextInt sc for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			} int j = 0; int j = 0; j 0 j < tmp j tmp j++ j++ j {
				k[i][sc.nextInt()-1] = 1;
			} {
				k[i][sc.nextInt()-1] = 1;
			} k[i][sc.nextInt()-1] = 1 k[i][sc.nextInt()-1] k[i] k i sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 1 int outp=0; outp 0 for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			}
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			}
		} {
			for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			}
		} for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			} {
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			} if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				} k[j][i] == 0 k[j][i] k[j] k j i 0 {
					break;
				} break; if(j == k.length-1){
					outp++;
				} j == k.length-1 j k.length-1 k.length k k.length 1 {
					outp++;
				} outp++ outp System.out.println(outp) System.out.println System.out System System.out outp String[] args args
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] k = new int[n][m];
		//input
		for(int i = 0; i < k.length; i++){
			int tmp = sc.nextInt();
			for(int j = 0; j < tmp; j++){
				k[i][sc.nextInt()-1] = 1;
			}
		}
		int outp=0;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(k[j][i] == 0){
					break;
				}else if(j == k.length-1){
					outp++;
				}
			}
		}
		System.out.println(outp);
	}
}