import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		// Input Example:
		//
		// N M
		// K1 A11 A12 ... A1k1
		// K2 A21 A22 ... A2k2
		// .
		// .
		// .
		// KN AN1 AN2 ... ANkN

		Scanner sc = new Scanner(System.in);
		// N people
		int N = sc.nextInt();
		
		// get two integers separated with half-width break
		// M kinds of foods
		int M = sc.nextInt();

		// int A[][] = new int[N][M]; 

		// Ki: the number of foods person i+1 like
		int K;

		// map[M]: the table of the likeness of each foods 
		int map[] = new int[M];

		for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		}

		int ans = 0;
		for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		}
		System.out.println(ans);
		
	}

} import java.util.*; util.* java public class Main {
	public static void main(String[] args)
	{
		// Input Example:
		//
		// N M
		// K1 A11 A12 ... A1k1
		// K2 A21 A22 ... A2k2
		// .
		// .
		// .
		// KN AN1 AN2 ... ANkN

		Scanner sc = new Scanner(System.in);
		// N people
		int N = sc.nextInt();
		
		// get two integers separated with half-width break
		// M kinds of foods
		int M = sc.nextInt();

		// int A[][] = new int[N][M]; 

		// Ki: the number of foods person i+1 like
		int K;

		// map[M]: the table of the likeness of each foods 
		int map[] = new int[M];

		for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		}

		int ans = 0;
		for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		}
		System.out.println(ans);
		
	}

} Main public static void main(String[] args)
	{
		// Input Example:
		//
		// N M
		// K1 A11 A12 ... A1k1
		// K2 A21 A22 ... A2k2
		// .
		// .
		// .
		// KN AN1 AN2 ... ANkN

		Scanner sc = new Scanner(System.in);
		// N people
		int N = sc.nextInt();
		
		// get two integers separated with half-width break
		// M kinds of foods
		int M = sc.nextInt();

		// int A[][] = new int[N][M]; 

		// Ki: the number of foods person i+1 like
		int K;

		// map[M]: the table of the likeness of each foods 
		int map[] = new int[M];

		for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		}

		int ans = 0;
		for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		}
		System.out.println(ans);
		
	} main {
		// Input Example:
		//
		// N M
		// K1 A11 A12 ... A1k1
		// K2 A21 A22 ... A2k2
		// .
		// .
		// .
		// KN AN1 AN2 ... ANkN

		Scanner sc = new Scanner(System.in);
		// N people
		int N = sc.nextInt();
		
		// get two integers separated with half-width break
		// M kinds of foods
		int M = sc.nextInt();

		// int A[][] = new int[N][M]; 

		// Ki: the number of foods person i+1 like
		int K;

		// map[M]: the table of the likeness of each foods 
		int map[] = new int[M];

		for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		}

		int ans = 0;
		for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		}
		System.out.println(ans);
		
	} 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; K int map[] = new int[M]; map new int[M] M for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		} {
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		} K = sc.nextInt() K sc.nextInt() sc.nextInt sc for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			} int j=0; int j=0; j 0 j<K j K j++ j++ j {
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			} {
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			} int K_temp; K_temp K_temp = sc.nextInt() K_temp sc.nextInt() sc.nextInt sc map[K_temp-1]++ map[K_temp-1] map K_temp-1 K_temp 1 int ans = 0; ans 0 for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		} int i=0; int i=0; i 0 i<M i M i++ i++ i {
			if (map[i] == N)
			{
				ans++;
			}
		} {
			if (map[i] == N)
			{
				ans++;
			}
		} if (map[i] == N)
			{
				ans++;
			} map[i] == N map[i] map i N {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args)
	{
		// Input Example:
		//
		// N M
		// K1 A11 A12 ... A1k1
		// K2 A21 A22 ... A2k2
		// .
		// .
		// .
		// KN AN1 AN2 ... ANkN

		Scanner sc = new Scanner(System.in);
		// N people
		int N = sc.nextInt();
		
		// get two integers separated with half-width break
		// M kinds of foods
		int M = sc.nextInt();

		// int A[][] = new int[N][M]; 

		// Ki: the number of foods person i+1 like
		int K;

		// map[M]: the table of the likeness of each foods 
		int map[] = new int[M];

		for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		}

		int ans = 0;
		for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		}
		System.out.println(ans);
		
	}

} public class Main {
	public static void main(String[] args)
	{
		// Input Example:
		//
		// N M
		// K1 A11 A12 ... A1k1
		// K2 A21 A22 ... A2k2
		// .
		// .
		// .
		// KN AN1 AN2 ... ANkN

		Scanner sc = new Scanner(System.in);
		// N people
		int N = sc.nextInt();
		
		// get two integers separated with half-width break
		// M kinds of foods
		int M = sc.nextInt();

		// int A[][] = new int[N][M]; 

		// Ki: the number of foods person i+1 like
		int K;

		// map[M]: the table of the likeness of each foods 
		int map[] = new int[M];

		for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		}

		int ans = 0;
		for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		}
		System.out.println(ans);
		
	}

} Main
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		// Input Example:
		//
		// N M
		// K1 A11 A12 ... A1k1
		// K2 A21 A22 ... A2k2
		// .
		// .
		// .
		// KN AN1 AN2 ... ANkN

		Scanner sc = new Scanner(System.in);
		// N people
		int N = sc.nextInt();
		
		// get two integers separated with half-width break
		// M kinds of foods
		int M = sc.nextInt();

		// int A[][] = new int[N][M]; 

		// Ki: the number of foods person i+1 like
		int K;

		// map[M]: the table of the likeness of each foods 
		int map[] = new int[M];

		for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		}

		int ans = 0;
		for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		}
		System.out.println(ans);
		
	}

}