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

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

		int[][] like = new int[n][];
		for (int i = 0; i < n; i++) {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		}

		int[] cnt = new int[food];

		for (int j = 0; j < like.length; j++) {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		}
		
		int ans = 0;
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		System.out.println(ans);

	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int food = sc.nextInt();

		int[][] like = new int[n][];
		for (int i = 0; i < n; i++) {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		}

		int[] cnt = new int[food];

		for (int j = 0; j < like.length; j++) {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		}
		
		int ans = 0;
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		System.out.println(ans);

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

		int[][] like = new int[n][];
		for (int i = 0; i < n; i++) {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		}

		int[] cnt = new int[food];

		for (int j = 0; j < like.length; j++) {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		}
		
		int ans = 0;
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		System.out.println(ans);

	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int food = sc.nextInt();

		int[][] like = new int[n][];
		for (int i = 0; i < n; i++) {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		}

		int[] cnt = new int[food];

		for (int j = 0; j < like.length; j++) {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		}
		
		int ans = 0;
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		System.out.println(ans);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int food = sc.nextInt(); food sc.nextInt() sc.nextInt sc int[][] like = new int[n][]; like new int[n][] n for (int i = 0; i < n; i++) {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		} {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		} int[] like2 = new int[sc.nextInt()]; like2 new int[sc.nextInt()] sc.nextInt() sc.nextInt sc for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			} int j = 0; int j = 0; j 0 j < like2.length j like2.length like2 like2.length j++ j++ j {
				like2[j] = sc.nextInt();
			} {
				like2[j] = sc.nextInt();
			} like2[j] = sc.nextInt() like2[j] like2 j sc.nextInt() sc.nextInt sc like[i] = like2 like[i] like i like2 int[] cnt = new int[food]; cnt new int[food] food for (int j = 0; j < like.length; j++) {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		} int j = 0; int j = 0; j 0 j < like.length j like.length like like.length j++ j++ j {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		} {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		} for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			} int k = 0; int k = 0; k 0 k < like[j].length k like[j].length like[j] like j like[j].length k++ k++ k {
				cnt[like[j][k] - 1]++;
			} {
				cnt[like[j][k] - 1]++;
			} cnt[like[j][k] - 1]++ cnt[like[j][k] - 1] cnt like[j][k] - 1 like[j][k] like[j] like j k 1 int ans = 0; ans 0 for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i < cnt.length i cnt.length cnt cnt.length i++ i++ i {
			if (cnt[i] == n) {
				ans++;
			}
		} {
			if (cnt[i] == n) {
				ans++;
			}
		} if (cnt[i] == n) {
				ans++;
			} cnt[i] == n cnt[i] cnt i n {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String args[] args

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

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

		int[][] like = new int[n][];
		for (int i = 0; i < n; i++) {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		}

		int[] cnt = new int[food];

		for (int j = 0; j < like.length; j++) {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		}
		
		int ans = 0;
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		System.out.println(ans);

	}
}