import java.util.Scanner;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i = 0; i < n; i++){
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		}
		if(n == 1){
			System.out.println(list.size());
		}else{
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i = 0; i < n; i++){
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		}
		if(n == 1){
			System.out.println(list.size());
		}else{
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i = 0; i < n; i++){
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		}
		if(n == 1){
			System.out.println(list.size());
		}else{
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i = 0; i < n; i++){
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		}
		if(n == 1){
			System.out.println(list.size());
		}else{
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc for(int i = 0; i < n; i++){
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		} 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 ik = sc.nextInt();
				list.add(ik);
			}
		} {
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				int ik = sc.nextInt();
				list.add(ik);
			} {
				int ik = sc.nextInt();
				list.add(ik);
			} int ik = sc.nextInt(); ik sc.nextInt() sc.nextInt sc list.add(ik) list.add list ik if(n == 1){
			System.out.println(list.size());
		}else{
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		} n == 1 n 1 {
			System.out.println(list.size());
		} System.out.println(list.size()) System.out.println System.out System System.out list.size() list.size list {
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		} int[] count = new int[m]; count new int[m] m int a = 0; a 0 for (int v : list) {
				count[v - 1]++;
			} int v list {
				count[v - 1]++;
			} {
				count[v - 1]++;
			} count[v - 1]++ count[v - 1] count v - 1 v 1 int cnt = 0; cnt 0 for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
				if(count[i] == n){
					cnt++;
				}
			} {
				if(count[i] == n){
					cnt++;
				}
			} if(count[i] == n){
					cnt++;
				} count[i] == n count[i] count i n {
					cnt++;
				} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i = 0; i < n; i++){
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		}
		if(n == 1){
			System.out.println(list.size());
		}else{
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i = 0; i < n; i++){
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		}
		if(n == 1){
			System.out.println(list.size());
		}else{
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
} Main
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		for(int i = 0; i < n; i++){
			int k = sc.nextInt();
			for(int j = 0; j < k; j++){
				int ik = sc.nextInt();
				list.add(ik);
			}
		}
		if(n == 1){
			System.out.println(list.size());
		}else{
			int[] count = new int[m];
			int a = 0;
			for (int v : list) {
				count[v - 1]++;
			}
			int cnt = 0;
			for(int i = 0; i < m; i++){
				if(count[i] == n){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}