
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().exec();
	}

	void exec() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int food[] = new int[m];

		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			}
		}
		int total = 0;
		for (int i = 0; i < m; i++) {
			if(food[i] == n) total++;
		}
		System.out.println(total);
		sc.close();
	}


} import java.util.Scanner; Scanner java.util class Main {

	public static void main(String[] args) {
		new Main().exec();
	}

	void exec() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int food[] = new int[m];

		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			}
		}
		int total = 0;
		for (int i = 0; i < m; i++) {
			if(food[i] == n) total++;
		}
		System.out.println(total);
		sc.close();
	}


} Main public static void main(String[] args) {
		new Main().exec();
	} main {
		new Main().exec();
	} new Main().exec() new Main().exec new Main() String[] args args void exec() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int food[] = new int[m];

		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			}
		}
		int total = 0;
		for (int i = 0; i < m; i++) {
			if(food[i] == n) total++;
		}
		System.out.println(total);
		sc.close();
	} exec {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int food[] = new int[m];

		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			}
		}
		int total = 0;
		for (int i = 0; i < m; i++) {
			if(food[i] == n) total++;
		}
		System.out.println(total);
		sc.close();
	} 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 int food[] = new int[m]; food new int[m] m for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			}
		} {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				int personalF = sc.nextInt();
				++food[personalF-1];
			} {
				int personalF = sc.nextInt();
				++food[personalF-1];
			} int personalF = sc.nextInt(); personalF sc.nextInt() sc.nextInt sc ++food[personalF-1] food[personalF-1] food personalF-1 personalF 1 int total = 0; total 0 for (int i = 0; i < m; i++) {
			if(food[i] == n) total++;
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			if(food[i] == n) total++;
		} {
			if(food[i] == n) total++;
		} if(food[i] == n) total++; food[i] == n food[i] food i n total++ total System.out.println(total) System.out.println System.out System System.out total sc.close() sc.close sc

import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().exec();
	}

	void exec() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int food[] = new int[m];

		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int personalF = sc.nextInt();
				++food[personalF-1];
			}
		}
		int total = 0;
		for (int i = 0; i < m; i++) {
			if(food[i] == n) total++;
		}
		System.out.println(total);
		sc.close();
	}


}
