import java.util.Arrays;
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();
		
		boolean[] map = new boolean[M];
		Arrays.fill(map, true);
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		}
		
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (map[i])
				ans++;
		}
		
		System.out.println(ans);
	}
	
} import java.util.Arrays; Arrays java.util 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();
		
		boolean[] map = new boolean[M];
		Arrays.fill(map, true);
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		}
		
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (map[i])
				ans++;
		}
		
		System.out.println(ans);
	}
	
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		boolean[] map = new boolean[M];
		Arrays.fill(map, true);
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		}
		
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (map[i])
				ans++;
		}
		
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		boolean[] map = new boolean[M];
		Arrays.fill(map, true);
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		}
		
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (map[i])
				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 boolean[] map = new boolean[M]; map new boolean[M] M Arrays.fill(map, true) Arrays.fill Arrays map true for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		} {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc boolean[] check = new boolean[M]; check new boolean[M] M for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
				int index = sc.nextInt();
				check[index-1] = true;
			} {
				int index = sc.nextInt();
				check[index-1] = true;
			} int index = sc.nextInt(); index sc.nextInt() sc.nextInt sc check[index-1] = true check[index-1] check index-1 index 1 true for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			} int j = 0; int j = 0; j 0 j < M j M j++ j++ j {
				map[j] &= check[j];
			} {
				map[j] &= check[j];
			} map[j] &= check[j] map[j] map j check[j] check j int ans = 0; ans 0 for (int i = 0; i < M; i++) {
			if (map[i])
				ans++;
		} int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
			if (map[i])
				ans++;
		} {
			if (map[i])
				ans++;
		} if (map[i])
				ans++; map[i] map i 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) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		boolean[] map = new boolean[M];
		Arrays.fill(map, true);
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		}
		
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (map[i])
				ans++;
		}
		
		System.out.println(ans);
	}
	
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		boolean[] map = new boolean[M];
		Arrays.fill(map, true);
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		}
		
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (map[i])
				ans++;
		}
		
		System.out.println(ans);
	}
	
} Main
import java.util.Arrays;
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();
		
		boolean[] map = new boolean[M];
		Arrays.fill(map, true);
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			boolean[] check = new boolean[M];
			for (int j = 0; j < K; j++) {
				int index = sc.nextInt();
				check[index-1] = true;
			}
			
			for (int j = 0; j < M; j++) {
				map[j] &= check[j];
			}
		}
		
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (map[i])
				ans++;
		}
		
		System.out.println(ans);
	}
	
}
