import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");
		int N = Integer.parseInt(data[0]);
		int M = Integer.parseInt(data[1]);
		int[] food = new int[M];
		for(int i=0;i<M;i++) {
			food[i]=0;
		}
		
		for(int i=0;i<N;i++) {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		}
		
		int cnt=0;
		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}
    	System.out.println(cnt);
	}
} import java.text.ParseException; ParseException java.text import java.text.SimpleDateFormat; SimpleDateFormat java.text import java.util.Date; Date java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");
		int N = Integer.parseInt(data[0]);
		int M = Integer.parseInt(data[1]);
		int[] food = new int[M];
		for(int i=0;i<M;i++) {
			food[i]=0;
		}
		
		for(int i=0;i<N;i++) {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		}
		
		int cnt=0;
		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}
    	System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");
		int N = Integer.parseInt(data[0]);
		int M = Integer.parseInt(data[1]);
		int[] food = new int[M];
		for(int i=0;i<M;i++) {
			food[i]=0;
		}
		
		for(int i=0;i<N;i++) {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		}
		
		int cnt=0;
		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}
    	System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");
		int N = Integer.parseInt(data[0]);
		int M = Integer.parseInt(data[1]);
		int[] food = new int[M];
		for(int i=0;i<M;i++) {
			food[i]=0;
		}
		
		for(int i=0;i<N;i++) {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		}
		
		int cnt=0;
		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}
    	System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] data = sc.nextLine().split(" "); data sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int N = Integer.parseInt(data[0]); N Integer.parseInt(data[0]) Integer.parseInt Integer data[0] data 0 int M = Integer.parseInt(data[1]); M Integer.parseInt(data[1]) Integer.parseInt Integer data[1] data 1 int[] food = new int[M]; food new int[M] M for(int i=0;i<M;i++) {
			food[i]=0;
		} int i=0; int i=0; i 0 i<M i M i++ i++ i {
			food[i]=0;
		} {
			food[i]=0;
		} food[i]=0 food[i] food i 0 for(int i=0;i<N;i++) {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		} {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		} data = sc.nextLine().split(" ") data sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int K = Integer.parseInt(data[0]); K Integer.parseInt(data[0]) Integer.parseInt Integer data[0] data 0 for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			} int j=1; int j=1; j 1 j<=K j K j++ j++ j {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			} {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			} int value = Integer.parseInt(data[j]); value Integer.parseInt(data[j]) Integer.parseInt Integer data[j] data j food[--value]++ food[--value] food --value value int cnt=0; cnt 0 for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		} int i=0; int i=0; i 0 i<M i M i++ i++ i {
			if(food[i]==N) cnt++;
		} {
			if(food[i]==N) cnt++;
		} if(food[i]==N) cnt++; food[i]==N food[i] food i N cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");
		int N = Integer.parseInt(data[0]);
		int M = Integer.parseInt(data[1]);
		int[] food = new int[M];
		for(int i=0;i<M;i++) {
			food[i]=0;
		}
		
		for(int i=0;i<N;i++) {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		}
		
		int cnt=0;
		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}
    	System.out.println(cnt);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");
		int N = Integer.parseInt(data[0]);
		int M = Integer.parseInt(data[1]);
		int[] food = new int[M];
		for(int i=0;i<M;i++) {
			food[i]=0;
		}
		
		for(int i=0;i<N;i++) {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		}
		
		int cnt=0;
		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}
    	System.out.println(cnt);
	}
} Main
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] data = sc.nextLine().split(" ");
		int N = Integer.parseInt(data[0]);
		int M = Integer.parseInt(data[1]);
		int[] food = new int[M];
		for(int i=0;i<M;i++) {
			food[i]=0;
		}
		
		for(int i=0;i<N;i++) {
			data = sc.nextLine().split(" ");
			int K = Integer.parseInt(data[0]);
			for(int j=1;j<=K;j++) {
				int value = Integer.parseInt(data[j]);
				food[--value]++;
			}
		}
		
		int cnt=0;
		for(int i=0;i<M;i++) {
			if(food[i]==N) cnt++;
		}
    	System.out.println(cnt);
	}
}
