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[]k = new int[n];
		int[]a = new int[n*m];
		int[]A = new int[m];

		for(int i=0; i<n; i++) {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		}
		int cou = 0;
		for(int i=0; i<m; i++) {
			if(A[i]== n) {
				cou++;
			}
		}
		System.out.println(cou);
	}
} 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[]k = new int[n];
		int[]a = new int[n*m];
		int[]A = new int[m];

		for(int i=0; i<n; i++) {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		}
		int cou = 0;
		for(int i=0; i<m; i++) {
			if(A[i]== n) {
				cou++;
			}
		}
		System.out.println(cou);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[]k = new int[n];
		int[]a = new int[n*m];
		int[]A = new int[m];

		for(int i=0; i<n; i++) {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		}
		int cou = 0;
		for(int i=0; i<m; i++) {
			if(A[i]== n) {
				cou++;
			}
		}
		System.out.println(cou);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[]k = new int[n];
		int[]a = new int[n*m];
		int[]A = new int[m];

		for(int i=0; i<n; i++) {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		}
		int cou = 0;
		for(int i=0; i<m; i++) {
			if(A[i]== n) {
				cou++;
			}
		}
		System.out.println(cou);
	} 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*m]; a new int[n*m] n*m n m int[]A = new int[m]; A new int[m] m for(int i=0; i<n; i++) {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		} 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] = sc.nextInt();
					A[a[i]-1]++;
				}
		} {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		} k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				} int j=0; int j=0; j 0 j<k[i] j k[i] k i j++ j++ j {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				} {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				} a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc A[a[i]-1]++ A[a[i]-1] A a[i]-1 a[i] a i 1 int cou = 0; cou 0 for(int i=0; i<m; i++) {
			if(A[i]== n) {
				cou++;
			}
		} int i=0; int i=0; i 0 i<m i m i++ i++ i {
			if(A[i]== n) {
				cou++;
			}
		} {
			if(A[i]== n) {
				cou++;
			}
		} if(A[i]== n) {
				cou++;
			} A[i]== n A[i] A i n {
				cou++;
			} cou++ cou System.out.println(cou) System.out.println System.out System System.out cou 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[]k = new int[n];
		int[]a = new int[n*m];
		int[]A = new int[m];

		for(int i=0; i<n; i++) {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		}
		int cou = 0;
		for(int i=0; i<m; i++) {
			if(A[i]== n) {
				cou++;
			}
		}
		System.out.println(cou);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[]k = new int[n];
		int[]a = new int[n*m];
		int[]A = new int[m];

		for(int i=0; i<n; i++) {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		}
		int cou = 0;
		for(int i=0; i<m; i++) {
			if(A[i]== n) {
				cou++;
			}
		}
		System.out.println(cou);
	}
} 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[]k = new int[n];
		int[]a = new int[n*m];
		int[]A = new int[m];

		for(int i=0; i<n; i++) {
			k[i] = sc.nextInt();
				for(int j=0; j<k[i]; j++) {
					a[i] = sc.nextInt();
					A[a[i]-1]++;
				}
		}
		int cou = 0;
		for(int i=0; i<m; i++) {
			if(A[i]== n) {
				cou++;
			}
		}
		System.out.println(cou);
	}
}
