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

//AtCoder Beginner Contest 118
//B	Foods Loved by Everyone
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		List<List<Integer>> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		}
		sc.close();

		int[] Ms = new int[M];
		for (int i = 0; i < Ms.length; i++) {
			Ms[i] = 0;
		}

		for (List<Integer> list : inList) {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		}

		int kind = 0;
		for (int i = 0; i < Ms.length; i++) {
			if (Ms[i] == N) {
				kind++;
			}
		}

		System.out.println(kind);
	}
} import java.util.ArrayList; ArrayList 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);
		int N = sc.nextInt();
		int M = sc.nextInt();

		List<List<Integer>> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		}
		sc.close();

		int[] Ms = new int[M];
		for (int i = 0; i < Ms.length; i++) {
			Ms[i] = 0;
		}

		for (List<Integer> list : inList) {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		}

		int kind = 0;
		for (int i = 0; i < Ms.length; i++) {
			if (Ms[i] == N) {
				kind++;
			}
		}

		System.out.println(kind);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		List<List<Integer>> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		}
		sc.close();

		int[] Ms = new int[M];
		for (int i = 0; i < Ms.length; i++) {
			Ms[i] = 0;
		}

		for (List<Integer> list : inList) {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		}

		int kind = 0;
		for (int i = 0; i < Ms.length; i++) {
			if (Ms[i] == N) {
				kind++;
			}
		}

		System.out.println(kind);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		List<List<Integer>> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		}
		sc.close();

		int[] Ms = new int[M];
		for (int i = 0; i < Ms.length; i++) {
			Ms[i] = 0;
		}

		for (List<Integer> list : inList) {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		}

		int kind = 0;
		for (int i = 0; i < Ms.length; i++) {
			if (Ms[i] == N) {
				kind++;
			}
		}

		System.out.println(kind);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc List<List<Integer>> inList = new ArrayList<>(); inList new ArrayList<>() for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		} {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc List<Integer> inListK = new ArrayList<>(); inListK new ArrayList<>() for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
				inListK.add(sc.nextInt());
			} {
				inListK.add(sc.nextInt());
			} inListK.add(sc.nextInt()) inListK.add inListK sc.nextInt() sc.nextInt sc inList.add(inListK) inList.add inList inListK sc.close() sc.close sc int[] Ms = new int[M]; Ms new int[M] M for (int i = 0; i < Ms.length; i++) {
			Ms[i] = 0;
		} int i = 0; int i = 0; i 0 i < Ms.length i Ms.length Ms Ms.length i++ i++ i {
			Ms[i] = 0;
		} {
			Ms[i] = 0;
		} Ms[i] = 0 Ms[i] Ms i 0 for (List<Integer> list : inList) {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		} List<Integer> list inList {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		} {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		} for (Integer i : list) {
				Ms[i.intValue()-1]++;
			} Integer i list {
				Ms[i.intValue()-1]++;
			} {
				Ms[i.intValue()-1]++;
			} Ms[i.intValue()-1]++ Ms[i.intValue()-1] Ms i.intValue()-1 i.intValue() i.intValue i 1 int kind = 0; kind 0 for (int i = 0; i < Ms.length; i++) {
			if (Ms[i] == N) {
				kind++;
			}
		} int i = 0; int i = 0; i 0 i < Ms.length i Ms.length Ms Ms.length i++ i++ i {
			if (Ms[i] == N) {
				kind++;
			}
		} {
			if (Ms[i] == N) {
				kind++;
			}
		} if (Ms[i] == N) {
				kind++;
			} Ms[i] == N Ms[i] Ms i N {
				kind++;
			} kind++ kind System.out.println(kind) System.out.println System.out System System.out kind String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		List<List<Integer>> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		}
		sc.close();

		int[] Ms = new int[M];
		for (int i = 0; i < Ms.length; i++) {
			Ms[i] = 0;
		}

		for (List<Integer> list : inList) {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		}

		int kind = 0;
		for (int i = 0; i < Ms.length; i++) {
			if (Ms[i] == N) {
				kind++;
			}
		}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		List<List<Integer>> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		}
		sc.close();

		int[] Ms = new int[M];
		for (int i = 0; i < Ms.length; i++) {
			Ms[i] = 0;
		}

		for (List<Integer> list : inList) {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		}

		int kind = 0;
		for (int i = 0; i < Ms.length; i++) {
			if (Ms[i] == N) {
				kind++;
			}
		}

		System.out.println(kind);
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//AtCoder Beginner Contest 118
//B	Foods Loved by Everyone
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		List<List<Integer>> inList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			List<Integer> inListK = new ArrayList<>();
			for (int j = 0; j < K; j++) {
				inListK.add(sc.nextInt());
			}
			inList.add(inListK);
		}
		sc.close();

		int[] Ms = new int[M];
		for (int i = 0; i < Ms.length; i++) {
			Ms[i] = 0;
		}

		for (List<Integer> list : inList) {
			for (Integer i : list) {
				Ms[i.intValue()-1]++;
			}
		}

		int kind = 0;
		for (int i = 0; i < Ms.length; i++) {
			if (Ms[i] == N) {
				kind++;
			}
		}

		System.out.println(kind);
	}
}
