import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] foods = new int[M];
		Arrays.fill(foods, 0);
		for (int i = 0; i < N; ++i) {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		}
		in.close();
		int result = 0;
		for (int i = 0; i < foods.length; ++i) {
			if (foods[i] == N) {
				++result;
			}
		}
		System.out.println(result);

	}

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

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] foods = new int[M];
		Arrays.fill(foods, 0);
		for (int i = 0; i < N; ++i) {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		}
		in.close();
		int result = 0;
		for (int i = 0; i < foods.length; ++i) {
			if (foods[i] == N) {
				++result;
			}
		}
		System.out.println(result);

	}

} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] foods = new int[M];
		Arrays.fill(foods, 0);
		for (int i = 0; i < N; ++i) {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		}
		in.close();
		int result = 0;
		for (int i = 0; i < foods.length; ++i) {
			if (foods[i] == N) {
				++result;
			}
		}
		System.out.println(result);

	} main {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] foods = new int[M];
		Arrays.fill(foods, 0);
		for (int i = 0; i < N; ++i) {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		}
		in.close();
		int result = 0;
		for (int i = 0; i < foods.length; ++i) {
			if (foods[i] == N) {
				++result;
			}
		}
		System.out.println(result);

	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String[] tokens = in.nextLine().split(" "); tokens in.nextLine().split(" ") in.nextLine().split in.nextLine() in.nextLine in " " int N = Integer.parseInt(tokens[0]); N Integer.parseInt(tokens[0]) Integer.parseInt Integer tokens[0] tokens 0 int M = Integer.parseInt(tokens[1]); M Integer.parseInt(tokens[1]) Integer.parseInt Integer tokens[1] tokens 1 int[] foods = new int[M]; foods new int[M] M Arrays.fill(foods, 0) Arrays.fill Arrays foods 0 for (int i = 0; i < N; ++i) {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		} int i = 0; int i = 0; i 0 i < N i N ++i ++i i {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		} {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		} Set<Integer> likeFoods = new HashSet<>(); likeFoods new HashSet<>() tokens = in.nextLine().split(" ") tokens in.nextLine().split(" ") in.nextLine().split in.nextLine() in.nextLine in " " int K = Integer.parseInt(tokens[0]); K Integer.parseInt(tokens[0]) Integer.parseInt Integer tokens[0] tokens 0 for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			} int j = 1; int j = 1; j 1 j <= K j K ++j ++j j {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			} {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			} int food = Integer.parseInt(tokens[j]); food Integer.parseInt(tokens[j]) Integer.parseInt Integer tokens[j] tokens j foods[food - 1]++ foods[food - 1] foods food - 1 food 1 in.close() in.close in int result = 0; result 0 for (int i = 0; i < foods.length; ++i) {
			if (foods[i] == N) {
				++result;
			}
		} int i = 0; int i = 0; i 0 i < foods.length i foods.length foods foods.length ++i ++i i {
			if (foods[i] == N) {
				++result;
			}
		} {
			if (foods[i] == N) {
				++result;
			}
		} if (foods[i] == N) {
				++result;
			} foods[i] == N foods[i] foods i N {
				++result;
			} ++result result System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] foods = new int[M];
		Arrays.fill(foods, 0);
		for (int i = 0; i < N; ++i) {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		}
		in.close();
		int result = 0;
		for (int i = 0; i < foods.length; ++i) {
			if (foods[i] == N) {
				++result;
			}
		}
		System.out.println(result);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] foods = new int[M];
		Arrays.fill(foods, 0);
		for (int i = 0; i < N; ++i) {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		}
		in.close();
		int result = 0;
		for (int i = 0; i < foods.length; ++i) {
			if (foods[i] == N) {
				++result;
			}
		}
		System.out.println(result);

	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] foods = new int[M];
		Arrays.fill(foods, 0);
		for (int i = 0; i < N; ++i) {
			Set<Integer> likeFoods = new HashSet<>();
			tokens = in.nextLine().split(" ");
			int K = Integer.parseInt(tokens[0]);
			for (int j = 1; j <= K; ++j) {
				int food = Integer.parseInt(tokens[j]);
				foods[food - 1]++;
			}
		}
		in.close();
		int result = 0;
		for (int i = 0; i < foods.length; ++i) {
			if (foods[i] == N) {
				++result;
			}
		}
		System.out.println(result);

	}

}