import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int interviewNum = sc.nextInt();
		int foodNum = sc.nextInt();
		int[] foods = new int[foodNum];
		for(int i = 0; i < foodNum; i++)foods[i] = 0;

		for(int i = 0; i < interviewNum; i++){
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			}
		}

		int ans = 0;
		for(int i : foods){
			if(i == interviewNum)ans++;
		}

		System.out.println(ans);
	}
}

 import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int interviewNum = sc.nextInt();
		int foodNum = sc.nextInt();
		int[] foods = new int[foodNum];
		for(int i = 0; i < foodNum; i++)foods[i] = 0;

		for(int i = 0; i < interviewNum; i++){
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			}
		}

		int ans = 0;
		for(int i : foods){
			if(i == interviewNum)ans++;
		}

		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int interviewNum = sc.nextInt();
		int foodNum = sc.nextInt();
		int[] foods = new int[foodNum];
		for(int i = 0; i < foodNum; i++)foods[i] = 0;

		for(int i = 0; i < interviewNum; i++){
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			}
		}

		int ans = 0;
		for(int i : foods){
			if(i == interviewNum)ans++;
		}

		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int interviewNum = sc.nextInt();
		int foodNum = sc.nextInt();
		int[] foods = new int[foodNum];
		for(int i = 0; i < foodNum; i++)foods[i] = 0;

		for(int i = 0; i < interviewNum; i++){
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			}
		}

		int ans = 0;
		for(int i : foods){
			if(i == interviewNum)ans++;
		}

		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int interviewNum = sc.nextInt(); interviewNum sc.nextInt() sc.nextInt sc int foodNum = sc.nextInt(); foodNum sc.nextInt() sc.nextInt sc int[] foods = new int[foodNum]; foods new int[foodNum] foodNum for(int i = 0; i < foodNum; i++)foods[i] = 0; int i = 0; int i = 0; i 0 i < foodNum i foodNum i++ i++ i foods[i] = 0; foods[i] = 0 foods[i] foods i 0 for(int i = 0; i < interviewNum; i++){
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			}
		} int i = 0; int i = 0; i 0 i < interviewNum i interviewNum i++ i++ i {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			}
		} {
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			}
		} int likeNum = sc.nextInt(); likeNum sc.nextInt() sc.nextInt sc for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			} int j = 0; int j = 0; j 0 j < likeNum j likeNum j++ j++ j {
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			} {
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			} int likeId = sc.nextInt(); likeId sc.nextInt() sc.nextInt sc foods[likeId-1]++ foods[likeId-1] foods likeId-1 likeId 1 int ans = 0; ans 0 for(int i : foods){
			if(i == interviewNum)ans++;
		} int i foods {
			if(i == interviewNum)ans++;
		} {
			if(i == interviewNum)ans++;
		} if(i == interviewNum)ans++; i == interviewNum i interviewNum ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int interviewNum = sc.nextInt();
		int foodNum = sc.nextInt();
		int[] foods = new int[foodNum];
		for(int i = 0; i < foodNum; i++)foods[i] = 0;

		for(int i = 0; i < interviewNum; i++){
			int likeNum = sc.nextInt();
			for(int j = 0; j < likeNum; j++){
				int likeId = sc.nextInt();
				foods[likeId-1]++;
			}
		}

		int ans = 0;
		for(int i : foods){
			if(i == interviewNum)ans++;
		}

		System.out.println(ans);
	}
}


