import java.util.*;
 
public class Main {
	static int count = 0;
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[][] A = new int[N][100];
		for (int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		}
 
		int[][] matrix = new int[N][M];
		for (int i=0; i<N; i++) {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		}
		
		int[] check = new int[M];
		for (int i=0; i<M; i++) {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		}
		
		System.out.println(count);
 
	}
 
} import java.util.*; util.* java public class Main {
	static int count = 0;
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[][] A = new int[N][100];
		for (int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		}
 
		int[][] matrix = new int[N][M];
		for (int i=0; i<N; i++) {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		}
		
		int[] check = new int[M];
		for (int i=0; i<M; i++) {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		}
		
		System.out.println(count);
 
	}
 
} Main static int count = 0; count 0 public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[][] A = new int[N][100];
		for (int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		}
 
		int[][] matrix = new int[N][M];
		for (int i=0; i<N; i++) {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		}
		
		int[] check = new int[M];
		for (int i=0; i<M; i++) {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		}
		
		System.out.println(count);
 
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[][] A = new int[N][100];
		for (int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		}
 
		int[][] matrix = new int[N][M];
		for (int i=0; i<N; i++) {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		}
		
		int[] check = new int[M];
		for (int i=0; i<M; i++) {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				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[] K = new int[N]; K new int[N] N int[][] A = new int[N][100]; A new int[N][100] N 100 for (int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		} {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		} K[i] = sc.nextInt() K[i] K i sc.nextInt() sc.nextInt sc for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			} int j=0; int j=0; j 0 j<K[i] j K[i] K i j++ j++ j {
				A[i][j] = sc.nextInt();
			} {
				A[i][j] = sc.nextInt();
			} A[i][j] = sc.nextInt() A[i][j] A[i] A i j sc.nextInt() sc.nextInt sc int[][] matrix = new int[N][M]; matrix new int[N][M] N M for (int i=0; i<N; i++) {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		} {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		} for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			} int j=0; int j=0; j 0 j<K[i] j K[i] K i j++ j++ j {
				matrix[i][A[i][j]-1] = 1;
			} {
				matrix[i][A[i][j]-1] = 1;
			} matrix[i][A[i][j]-1] = 1 matrix[i][A[i][j]-1] matrix[i] matrix i A[i][j]-1 A[i][j] A[i] A i j 1 1 int[] check = new int[M]; check new int[M] M for (int i=0; i<M; i++) {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		} int i=0; int i=0; i 0 i<M i M i++ i++ i {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		} {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		} for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			} int j=0; int j=0; j 0 j<N j N j++ j++ j {
				check[i] += matrix[j][i];
			} {
				check[i] += matrix[j][i];
			} check[i] += matrix[j][i] check[i] check i matrix[j][i] matrix[j] matrix j i if(check[i]==N) {
				count++;
			} check[i]==N check[i] check i N {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	static int count = 0;
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[][] A = new int[N][100];
		for (int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		}
 
		int[][] matrix = new int[N][M];
		for (int i=0; i<N; i++) {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		}
		
		int[] check = new int[M];
		for (int i=0; i<M; i++) {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		}
		
		System.out.println(count);
 
	}
 
} public class Main {
	static int count = 0;
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[][] A = new int[N][100];
		for (int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		}
 
		int[][] matrix = new int[N][M];
		for (int i=0; i<N; i++) {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		}
		
		int[] check = new int[M];
		for (int i=0; i<M; i++) {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		}
		
		System.out.println(count);
 
	}
 
} Main
import java.util.*;
 
public class Main {
	static int count = 0;
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[][] A = new int[N][100];
		for (int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for (int j=0; j<K[i]; j++) {
				A[i][j] = sc.nextInt();
			}
		}
 
		int[][] matrix = new int[N][M];
		for (int i=0; i<N; i++) {
			for (int j=0; j<K[i]; j++) {
				matrix[i][A[i][j]-1] = 1;
			}
		}
		
		int[] check = new int[M];
		for (int i=0; i<M; i++) {
			for (int j=0; j<N; j++) {
				check[i] += matrix[j][i];
			}
			
			if(check[i]==N) {
				count++;
			}
		}
		
		System.out.println(count);
 
	}
 
}