import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);
		boolean[] dislike = new boolean[M];
		for(int i=0;i<N;i++){
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		}
		int cnt = 0;
		for(int i=0;i<M;i++){
			if(!dislike[i]){
				cnt++;
			}
		}
		System.out.println(cnt);
		return;
	}

	private static String readLine(){
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	static BufferedReader reader;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);
		boolean[] dislike = new boolean[M];
		for(int i=0;i<N;i++){
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		}
		int cnt = 0;
		for(int i=0;i<M;i++){
			if(!dislike[i]){
				cnt++;
			}
		}
		System.out.println(cnt);
		return;
	}

	private static String readLine(){
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	}
} Main static BufferedReader reader; reader public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);
		boolean[] dislike = new boolean[M];
		for(int i=0;i<N;i++){
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		}
		int cnt = 0;
		for(int i=0;i<M;i++){
			if(!dislike[i]){
				cnt++;
			}
		}
		System.out.println(cnt);
		return;
	} main {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);
		boolean[] dislike = new boolean[M];
		for(int i=0;i<N;i++){
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		}
		int cnt = 0;
		for(int i=0;i<M;i++){
			if(!dislike[i]){
				cnt++;
			}
		}
		System.out.println(cnt);
		return;
	} reader = new BufferedReader(new InputStreamReader(System.in)) reader new BufferedReader(new InputStreamReader(System.in)) String[] s = readLine().split(" "); s readLine().split(" ") readLine().split readLine() readLine " " int N = Integer.parseInt(s[0]); N Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 int M = Integer.parseInt(s[1]); M Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 boolean[] dislike = new boolean[M]; dislike new boolean[M] M for(int i=0;i<N;i++){
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		} {
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		} String[] st = readLine().split(" "); st readLine().split(" ") readLine().split readLine() readLine " " boolean[] l_tmp = new boolean[M]; l_tmp new boolean[M] M int ki = Integer.parseInt(st[0]); ki Integer.parseInt(st[0]) Integer.parseInt Integer st[0] st 0 for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			} int j=0; int j=0; j 0 j<ki j ki j++ j++ j {
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			} {
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			} l_tmp[Integer.parseInt(st[j+1])-1] = true l_tmp[Integer.parseInt(st[j+1])-1] l_tmp Integer.parseInt(st[j+1])-1 Integer.parseInt(st[j+1]) Integer.parseInt Integer st[j+1] st j+1 j 1 1 true for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			} int j=0; int j=0; j 0 j<M j M j++ j++ j {
				if(!l_tmp[j]){dislike[j]=true;}
			} {
				if(!l_tmp[j]){dislike[j]=true;}
			} if(!l_tmp[j]){dislike[j]=true;} !l_tmp[j] l_tmp[j] l_tmp j {dislike[j]=true;} dislike[j]=true dislike[j] dislike j true int cnt = 0; cnt 0 for(int i=0;i<M;i++){
			if(!dislike[i]){
				cnt++;
			}
		} int i=0; int i=0; i 0 i<M i M i++ i++ i {
			if(!dislike[i]){
				cnt++;
			}
		} {
			if(!dislike[i]){
				cnt++;
			}
		} if(!dislike[i]){
				cnt++;
			} !dislike[i] dislike[i] dislike i {
				cnt++;
			} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt return; String[] args args private static String readLine(){
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	} readLine {
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	} try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		} catch(Exception e){
			return e.getMessage();
		} Exception e {
			return e.getMessage();
		} return e.getMessage(); e.getMessage() e.getMessage e {
			return reader.readLine();
		} return reader.readLine(); reader.readLine() reader.readLine reader public class Main {

	static BufferedReader reader;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);
		boolean[] dislike = new boolean[M];
		for(int i=0;i<N;i++){
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		}
		int cnt = 0;
		for(int i=0;i<M;i++){
			if(!dislike[i]){
				cnt++;
			}
		}
		System.out.println(cnt);
		return;
	}

	private static String readLine(){
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	}
} public class Main {

	static BufferedReader reader;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);
		boolean[] dislike = new boolean[M];
		for(int i=0;i<N;i++){
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		}
		int cnt = 0;
		for(int i=0;i<M;i++){
			if(!dislike[i]){
				cnt++;
			}
		}
		System.out.println(cnt);
		return;
	}

	private static String readLine(){
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);
		boolean[] dislike = new boolean[M];
		for(int i=0;i<N;i++){
			String[] st = readLine().split(" ");
			boolean[] l_tmp = new boolean[M];
			int ki = Integer.parseInt(st[0]);
			for(int j=0;j<ki;j++){
				l_tmp[Integer.parseInt(st[j+1])-1] = true;
			}
			for(int j=0;j<M;j++){
				if(!l_tmp[j]){dislike[j]=true;}
			}
			
		}
		int cnt = 0;
		for(int i=0;i<M;i++){
			if(!dislike[i]){
				cnt++;
			}
		}
		System.out.println(cnt);
		return;
	}

	private static String readLine(){
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	}
}