import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] disliked = new boolean[m];
		
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			Set<Integer> isLiked = new HashSet<Integer>();
			for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			}
			for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < m; i++) {
			if(!disliked[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}
 import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] disliked = new boolean[m];
		
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			Set<Integer> isLiked = new HashSet<Integer>();
			for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			}
			for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < m; i++) {
			if(!disliked[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[] disliked = new boolean[m];
		
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			Set<Integer> isLiked = new HashSet<Integer>();
			for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			}
			for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < m; i++) {
			if(!disliked[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] disliked = new boolean[m];
		
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			Set<Integer> isLiked = new HashSet<Integer>();
			for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			}
			for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < m; i++) {
			if(!disliked[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[] disliked = new boolean[m]; disliked new boolean[m] m for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			Set<Integer> isLiked = new HashSet<Integer>();
			for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			}
			for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int k = sc.nextInt();
			Set<Integer> isLiked = new HashSet<Integer>();
			for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			}
			for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			}
		} {
			int k = sc.nextInt();
			Set<Integer> isLiked = new HashSet<Integer>();
			for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			}
			for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc Set<Integer> isLiked = new HashSet<Integer>(); isLiked new HashSet<Integer>() for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			} {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			} int a = sc.nextInt() - 1; a sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 isLiked.add(a) isLiked.add isLiked a for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			} int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			} {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			} if(!isLiked.contains(j)) {
					disliked[j] = true;
				} !isLiked.contains(j) isLiked.contains(j) isLiked.contains isLiked j {
					disliked[j] = true;
				} disliked[j] = true disliked[j] disliked j true int ans = 0; ans 0 for(int i = 0; i < m; i++) {
			if(!disliked[i]) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			if(!disliked[i]) {
				ans++;
			}
		} {
			if(!disliked[i]) {
				ans++;
			}
		} if(!disliked[i]) {
				ans++;
			} !disliked[i] disliked[i] disliked i {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] disliked = new boolean[m];
		
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			Set<Integer> isLiked = new HashSet<Integer>();
			for(int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				isLiked.add(a);
			}
			for(int j = 0; j < m; j++) {
				if(!isLiked.contains(j)) {
					disliked[j] = true;
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < m; i++) {
			if(!disliked[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

