import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = br.readLine().split(" ", 2);
		int n = Integer.parseInt(arr[0]);
		int m = Integer.parseInt(arr[1]);
		int[] menues = new int[m + 1];
		for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		}
		int count = 0;
		for (int x : menues) {
			if (x == n) {
				count++;
			}
		}
		System.out.println(count);
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = br.readLine().split(" ", 2);
		int n = Integer.parseInt(arr[0]);
		int m = Integer.parseInt(arr[1]);
		int[] menues = new int[m + 1];
		for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		}
		int count = 0;
		for (int x : menues) {
			if (x == n) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = br.readLine().split(" ", 2);
		int n = Integer.parseInt(arr[0]);
		int m = Integer.parseInt(arr[1]);
		int[] menues = new int[m + 1];
		for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		}
		int count = 0;
		for (int x : menues) {
			if (x == n) {
				count++;
			}
		}
		System.out.println(count);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = br.readLine().split(" ", 2);
		int n = Integer.parseInt(arr[0]);
		int m = Integer.parseInt(arr[1]);
		int[] menues = new int[m + 1];
		for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		}
		int count = 0;
		for (int x : menues) {
			if (x == n) {
				count++;
			}
		}
		System.out.println(count);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] arr = br.readLine().split(" ", 2); arr br.readLine().split(" ", 2) br.readLine().split br.readLine() br.readLine br " " 2 int n = Integer.parseInt(arr[0]); n Integer.parseInt(arr[0]) Integer.parseInt Integer arr[0] arr 0 int m = Integer.parseInt(arr[1]); m Integer.parseInt(arr[1]) Integer.parseInt Integer arr[1] arr 1 int[] menues = new int[m + 1]; menues new int[m + 1] m + 1 m 1 for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		} {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		} arr = br.readLine().split(" ") arr br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int k = Integer.parseInt(arr[0]); k Integer.parseInt(arr[0]) Integer.parseInt Integer arr[0] arr 0 for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			} int j = 1; int j = 1; j 1 j <= k j k j++ j++ j {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			} {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			} int a = Integer.parseInt(arr[j]); a Integer.parseInt(arr[j]) Integer.parseInt Integer arr[j] arr j menues[a]++ menues[a] menues a int count = 0; count 0 for (int x : menues) {
			if (x == n) {
				count++;
			}
		} int x menues {
			if (x == n) {
				count++;
			}
		} {
			if (x == n) {
				count++;
			}
		} if (x == n) {
				count++;
			} x == n x n {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = br.readLine().split(" ", 2);
		int n = Integer.parseInt(arr[0]);
		int m = Integer.parseInt(arr[1]);
		int[] menues = new int[m + 1];
		for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		}
		int count = 0;
		for (int x : menues) {
			if (x == n) {
				count++;
			}
		}
		System.out.println(count);
	}
} public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = br.readLine().split(" ", 2);
		int n = Integer.parseInt(arr[0]);
		int m = Integer.parseInt(arr[1]);
		int[] menues = new int[m + 1];
		for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		}
		int count = 0;
		for (int x : menues) {
			if (x == n) {
				count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = br.readLine().split(" ", 2);
		int n = Integer.parseInt(arr[0]);
		int m = Integer.parseInt(arr[1]);
		int[] menues = new int[m + 1];
		for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		}
		int count = 0;
		for (int x : menues) {
			if (x == n) {
				count++;
			}
		}
		System.out.println(count);
	}
}
