import java.math.BigInteger;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

} import java.math.BigInteger; BigInteger java.math import java.util.*; util.* java public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

} Main private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		}
	} doit {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		} sc.hasNext() sc.hasNext sc {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int [] acc = new int[m]; acc new int[m] m for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			} {
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			} int count = sc.nextInt(); count sc.nextInt() sc.nextInt sc for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				} int j = 0; int j = 0; j 0 j < count j count j++ j++ j {
					acc[sc.nextInt()-1]++;
				} {
					acc[sc.nextInt()-1]++;
				} acc[sc.nextInt()-1]++ acc[sc.nextInt()-1] acc sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 int ans = 0; ans 0 for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				if(acc[i] == n)ans++;
			} {
				if(acc[i] == n)ans++;
			} if(acc[i] == n)ans++; acc[i] == n acc[i] acc i n ans++ ans System.out.println(ans) System.out.println System.out System System.out ans private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	} debug {
		System.out.println("debug = " + Arrays.deepToString(o));
	} System.out.println("debug = " + Arrays.deepToString(o)) System.out.println System.out System System.out "debug = " + Arrays.deepToString(o) "debug = " Arrays.deepToString(o) Arrays.deepToString Arrays o Object... o o public static void main(String[] args) {
		new Main().doit();
	} main {
		new Main().doit();
	} new Main().doit() new Main().doit new Main() String[] args args public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

} public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

} Main
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}
