import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int res = 0;
			int[] array = new int[m+1];
			for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			}
			for(int score : array) {
				if(score==n) {
					res++;
				}
			}
			System.out.println(res);
			
			
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

} import java.util.*; util.* java public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int res = 0;
			int[] array = new int[m+1];
			for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			}
			for(int score : array) {
				if(score==n) {
					res++;
				}
			}
			System.out.println(res);
			
			
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

} Main static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int res = 0;
			int[] array = new int[m+1];
			for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			}
			for(int score : array) {
				if(score==n) {
					res++;
				}
			}
			System.out.println(res);
			
			
			sc.close();
		} solve {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int res = 0;
			int[] array = new int[m+1];
			for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			}
			for(int score : array) {
				if(score==n) {
					res++;
				}
			}
			System.out.println(res);
			
			
			sc.close();
		} 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 res = 0; res 0 int[] array = new int[m+1]; array new int[m+1] m+1 m 1 for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			} 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++) {
					array[sc.nextInt()]++;
				}
			} {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				} int j = 0; int j = 0; j 0 j<k j k j++ j++ j {
					array[sc.nextInt()]++;
				} {
					array[sc.nextInt()]++;
				} array[sc.nextInt()]++ array[sc.nextInt()] array sc.nextInt() sc.nextInt sc for(int score : array) {
				if(score==n) {
					res++;
				}
			} int score array {
				if(score==n) {
					res++;
				}
			} {
				if(score==n) {
					res++;
				}
			} if(score==n) {
					res++;
				} score==n score n {
					res++;
				} res++ res System.out.println(res) System.out.println System.out System System.out res sc.close() sc.close sc public static void main(String[] args) {
		solve();

	} main {
		solve();

	} solve() solve String[] args args public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int res = 0;
			int[] array = new int[m+1];
			for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			}
			for(int score : array) {
				if(score==n) {
					res++;
				}
			}
			System.out.println(res);
			
			
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

} public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int res = 0;
			int[] array = new int[m+1];
			for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			}
			for(int score : array) {
				if(score==n) {
					res++;
				}
			}
			System.out.println(res);
			
			
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

} Main
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int res = 0;
			int[] array = new int[m+1];
			for(int i = 0;i<n;i++) {
				int k = sc.nextInt();
				for(int j = 0;j<k;j++) {
					array[sc.nextInt()]++;
				}
			}
			for(int score : array) {
				if(score==n) {
					res++;
				}
			}
			System.out.println(res);
			
			
			sc.close();
		}
	public static void main(String[] args) {
		solve();

	}

}
