import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] food = new int[m];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
}

 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();
		
		int[] food = new int[m];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] food = new int[m];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] food = new int[m];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		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 int cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		} 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 a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		} {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			} {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			} int a= sc.nextInt(); a sc.nextInt() sc.nextInt sc a-- a food[a]++ food[a] food a if (food[a] == n) cnt++; food[a] == n food[a] food a n cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt sc.close() sc.close sc 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();
		
		int[] food = new int[m];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] food = new int[m];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] food = new int[m];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a= sc.nextInt();
				a--;
				food[a]++;
				if (food[a] == n) cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
}


