import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		String [][] tt = new String[N][];
		for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		}

		List<String> a = new ArrayList<String>();
		a = Arrays.asList(tt[0]);
		List<String> ans = new ArrayList<>(a);
		ans.remove(0);

		List<String> t = new ArrayList<String>();
		for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		}

		System.out.println(ans.size());
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List 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[] s = sc.nextLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		String [][] tt = new String[N][];
		for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		}

		List<String> a = new ArrayList<String>();
		a = Arrays.asList(tt[0]);
		List<String> ans = new ArrayList<>(a);
		ans.remove(0);

		List<String> t = new ArrayList<String>();
		for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		}

		System.out.println(ans.size());
	}
} Main public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		String [][] tt = new String[N][];
		for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		}

		List<String> a = new ArrayList<String>();
		a = Arrays.asList(tt[0]);
		List<String> ans = new ArrayList<>(a);
		ans.remove(0);

		List<String> t = new ArrayList<String>();
		for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		}

		System.out.println(ans.size());
	} main {

		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		String [][] tt = new String[N][];
		for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		}

		List<String> a = new ArrayList<String>();
		a = Arrays.asList(tt[0]);
		List<String> ans = new ArrayList<>(a);
		ans.remove(0);

		List<String> t = new ArrayList<String>();
		for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		}

		System.out.println(ans.size());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] s = sc.nextLine().split(" "); s sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " 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 String [][] tt = new String[N][]; tt new String[N][] N for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			tt[i] = sc.nextLine().split(" ");
		} {
			tt[i] = sc.nextLine().split(" ");
		} tt[i] = sc.nextLine().split(" ") tt[i] tt i sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " List<String> a = new ArrayList<String>(); a new ArrayList<String>() a = Arrays.asList(tt[0]) a Arrays.asList(tt[0]) Arrays.asList Arrays tt[0] tt 0 List<String> ans = new ArrayList<>(a); ans new ArrayList<>(a) ans.remove(0) ans.remove ans 0 List<String> t = new ArrayList<String>(); t new ArrayList<String>() for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		} int i=1; int i=1; i 1 i<N i N i++ i++ i {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		} {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		} t = Arrays.asList(tt[i]) t Arrays.asList(tt[i]) Arrays.asList Arrays tt[i] tt i List<String> temp = new ArrayList<>(t); temp new ArrayList<>(t) int K = Integer.parseInt(temp.get(0)); K Integer.parseInt(temp.get(0)) Integer.parseInt Integer temp.get(0) temp.get temp 0 temp.remove(0) temp.remove temp 0 int j = 0; j 0 while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			} j < ans.size() j ans.size() ans.size ans {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			} if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				} temp.indexOf(ans.get(j)) < 0 temp.indexOf(ans.get(j)) temp.indexOf temp ans.get(j) ans.get ans j 0 {
					ans.remove(j);
				} ans.remove(j) ans.remove ans j {
					j++;
				} j++ j System.out.println(ans.size()) System.out.println System.out System System.out ans.size() ans.size ans String args[] args public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		String [][] tt = new String[N][];
		for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		}

		List<String> a = new ArrayList<String>();
		a = Arrays.asList(tt[0]);
		List<String> ans = new ArrayList<>(a);
		ans.remove(0);

		List<String> t = new ArrayList<String>();
		for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		}

		System.out.println(ans.size());
	}
} public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		String [][] tt = new String[N][];
		for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		}

		List<String> a = new ArrayList<String>();
		a = Arrays.asList(tt[0]);
		List<String> ans = new ArrayList<>(a);
		ans.remove(0);

		List<String> t = new ArrayList<String>();
		for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		}

		System.out.println(ans.size());
	}
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split(" ");

		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);

		String [][] tt = new String[N][];
		for(int i=0;i<N;i++) {
			tt[i] = sc.nextLine().split(" ");
		}

		List<String> a = new ArrayList<String>();
		a = Arrays.asList(tt[0]);
		List<String> ans = new ArrayList<>(a);
		ans.remove(0);

		List<String> t = new ArrayList<String>();
		for (int i=1;i<N;i++) {
			t = Arrays.asList(tt[i]);
			List<String> temp = new ArrayList<>(t);
			int K = Integer.parseInt(temp.get(0));
			temp.remove(0);

			int j = 0;
			while(j < ans.size()) {
				if(temp.indexOf(ans.get(j)) < 0) {
					ans.remove(j);
				}else {
					j++;
				}
			}
		}

		System.out.println(ans.size());
	}
}
