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 c [][] = new int [N][M+1];
		for (int i=0; i<N; i++){
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		}
		int ans = 0;
		for (int j=1; j<M+1; j++){
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		}
		System.out.println(ans);
		sc.close();

	}

} 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 c [][] = new int [N][M+1];
		for (int i=0; i<N; i++){
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		}
		int ans = 0;
		for (int j=1; j<M+1; j++){
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		}
		System.out.println(ans);
		sc.close();

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int c [][] = new int [N][M+1];
		for (int i=0; i<N; i++){
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		}
		int ans = 0;
		for (int j=1; j<M+1; j++){
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		}
		System.out.println(ans);
		sc.close();

	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int c [][] = new int [N][M+1];
		for (int i=0; i<N; i++){
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		}
		int ans = 0;
		for (int j=1; j<M+1; j++){
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		}
		System.out.println(ans);
		sc.close();

	} 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 c [][] = new int [N][M+1]; c new int [N][M+1] N M+1 M 1 for (int i=0; i<N; i++){
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		} {
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			} int j=0; int j=0; j 0 j<K j K j++ j++ j {
				int cij=sc.nextInt();
				c[i][cij]=1;
			} {
				int cij=sc.nextInt();
				c[i][cij]=1;
			} int cij=sc.nextInt(); cij sc.nextInt() sc.nextInt sc c[i][cij]=1 c[i][cij] c[i] c i cij 1 int ans = 0; ans 0 for (int j=1; j<M+1; j++){
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		} int j=1; int j=1; j 1 j<M+1 j M+1 M 1 j++ j++ j {
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		} {
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		} int temp = 0; temp 0 for  (int i=0; i<N; i++){
			temp+=c[i][j];
			} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			temp+=c[i][j];
			} {
			temp+=c[i][j];
			} temp+=c[i][j] temp c[i][j] c[i] c i j if (temp==N)
				ans++; temp==N temp N ans++ ans System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc 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 c [][] = new int [N][M+1];
		for (int i=0; i<N; i++){
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		}
		int ans = 0;
		for (int j=1; j<M+1; j++){
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		}
		System.out.println(ans);
		sc.close();

	}

} public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int c [][] = new int [N][M+1];
		for (int i=0; i<N; i++){
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		}
		int ans = 0;
		for (int j=1; j<M+1; j++){
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		}
		System.out.println(ans);
		sc.close();

	}

} 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 c [][] = new int [N][M+1];
		for (int i=0; i<N; i++){
			int K = sc.nextInt();
			
			for (int j=0; j<K; j++){
				int cij=sc.nextInt();
				c[i][cij]=1;
			}
		}
		int ans = 0;
		for (int j=1; j<M+1; j++){
			int temp = 0;
			for  (int i=0; i<N; i++){
			temp+=c[i][j];
			}
			if (temp==N)
				ans++;
		}
		System.out.println(ans);
		sc.close();

	}

}
