

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean fav[][] = new boolean[n][m];

		for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		}

		int count = 0;

loop:		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(!fav[j][i]){
					continue loop;
				}
			}

			count++;
		}

		System.out.println(count);
	}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean fav[][] = new boolean[n][m];

		for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		}

		int count = 0;

loop:		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(!fav[j][i]){
					continue loop;
				}
			}

			count++;
		}

		System.out.println(count);
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean fav[][] = new boolean[n][m];

		for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		}

		int count = 0;

loop:		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(!fav[j][i]){
					continue loop;
				}
			}

			count++;
		}

		System.out.println(count);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean fav[][] = new boolean[n][m];

		for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		}

		int count = 0;

loop:		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(!fav[j][i]){
					continue loop;
				}
			}

			count++;
		}

		System.out.println(count);
	} 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 boolean fav[][] = new boolean[n][m]; fav new boolean[n][m] n m for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		} 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++){
				fav[i][sc.nextInt() - 1] = true;
			}
		} {
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				fav[i][sc.nextInt() - 1] = true;
			} {
				fav[i][sc.nextInt() - 1] = true;
			} fav[i][sc.nextInt() - 1] = true fav[i][sc.nextInt() - 1] fav[i] fav i sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 true int count = 0; count 0 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean fav[][] = new boolean[n][m];

		for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		}

		int count = 0;

loop:		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(!fav[j][i]){
					continue loop;
				}
			}

			count++;
		}

		System.out.println(count);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean fav[][] = new boolean[n][m];

		for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		}

		int count = 0;

loop:		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(!fav[j][i]){
					continue loop;
				}
			}

			count++;
		}

		System.out.println(count);
	}

} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean fav[][] = new boolean[n][m];

		for(int i = 0; i < n; i++){
			int k = sc.nextInt();

			for(int j = 0; j < k; j++){
				fav[i][sc.nextInt() - 1] = true;
			}
		}

		int count = 0;

loop:		for(int i = 0; i < m; i++){
			for(int j = 0; j < n; j++){
				if(!fav[j][i]){
					continue loop;
				}
			}

			count++;
		}

		System.out.println(count);
	}

}
