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 count = 0;
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		}
		for(int i = 0; i < m; i++) {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		}
		System.out.println(count);
	}
} 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 count = 0;
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		}
		for(int i = 0; i < m; i++) {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count = 0;
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		}
		for(int i = 0; i < m; i++) {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count = 0;
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		}
		for(int i = 0; i < m; i++) {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		}
		System.out.println(count);
	} 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 count = 0; count 0 int[][] a = new int[n][m]; a new int[n][m] n m for(int i = 0; i < n; i++) {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		} {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		} for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			} int j = 0; int j = 0; j 0 j <m j m j++ j++ j {
				a[i][j] = 0;
			} {
				a[i][j] = 0;
			} a[i][j] = 0 a[i][j] a[i] a i j 0 for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		} {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			} {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			} int temp = sc.nextInt()-1; temp sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 a[i][temp] = 1 a[i][temp] a[i] a i temp 1 for(int i = 0; i < m; i++) {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		} {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		} boolean flag = true; flag true for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			} int j = 0; int j = 0; j 0 j <n j n j++ j++ j {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			} {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			} if(a[j][i]==0) {
					flag = false;
					break;
				} a[j][i]==0 a[j][i] a[j] a j i 0 {
					flag = false;
					break;
				} flag = false flag false break; if(flag) {
				count++;
			} flag {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count 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 count = 0;
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		}
		for(int i = 0; i < m; i++) {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count = 0;
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		}
		for(int i = 0; i < m; i++) {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		}
		System.out.println(count);
	}
} 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 count = 0;
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j <m; j++) {
				a[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++) {
				int temp = sc.nextInt()-1;
				a[i][temp] = 1;
			}
		}
		for(int i = 0; i < m; i++) {
			boolean flag = true;
			for(int j = 0; j <n; j++) {
				if(a[j][i]==0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				count++;
			}
		}
		System.out.println(count);
	}
}
