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[] food=new int[M];

		for(int i=0;i<N;i++) {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		}

		int cnt=0;

		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}

		System.out.println(cnt);

		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[] food=new int[M];

		for(int i=0;i<N;i++) {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		}

		int cnt=0;

		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}

		System.out.println(cnt);

		sc.close();

	}

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

		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();
		int M=sc.nextInt();

		int[] food=new int[M];

		for(int i=0;i<N;i++) {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		}

		int cnt=0;

		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}

		System.out.println(cnt);

		sc.close();

	} main {

		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();
		int M=sc.nextInt();

		int[] food=new int[M];

		for(int i=0;i<N;i++) {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		}

		int cnt=0;

		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}

		System.out.println(cnt);

		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[] food=new int[M]; food new int[M] M for(int i=0;i<N;i++) {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		} {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		} int J=sc.nextInt(); J sc.nextInt() sc.nextInt sc for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			} int j=0; int j=0; j 0 j<J j J j++ j++ j {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			} {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			} int inputFood=sc.nextInt()-1; inputFood sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 food[inputFood]++ food[inputFood] food inputFood int cnt=0; cnt 0 for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		} int i=0; int i=0; i 0 i<M i M i++ i++ i {
			if(food[i]==N) cnt++;
		} {
			if(food[i]==N) cnt++;
		} if(food[i]==N) cnt++; food[i]==N food[i] food i N cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt 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[] food=new int[M];

		for(int i=0;i<N;i++) {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		}

		int cnt=0;

		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}

		System.out.println(cnt);

		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[] food=new int[M];

		for(int i=0;i<N;i++) {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		}

		int cnt=0;

		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}

		System.out.println(cnt);

		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[] food=new int[M];

		for(int i=0;i<N;i++) {
			int J=sc.nextInt();
			for(int j=0;j<J;j++) {
				int inputFood=sc.nextInt()-1;
				food[inputFood]++;
			}
		}

		int cnt=0;

		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}

		System.out.println(cnt);

		sc.close();

	}

}
