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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] cnt = new int[m];
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < m; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
} import java.io.*; io.* java import java.util.Scanner; Scanner java.util public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] cnt = new int[m];
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < m; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
} Main private static Scanner sc; sc private static Printer pr; pr private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] cnt = new int[m];
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < m; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		pr.println(ans);
	} solve {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] cnt = new int[m];
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < m; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		pr.println(ans);
	} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] cnt = new int[m]; cnt new int[m] m for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		} 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() - 1;
				cnt[a]++;
			}
		} {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			} {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			} int a = sc.nextInt() - 1; a sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 cnt[a]++ cnt[a] cnt a int ans = 0; ans 0 for (int i = 0; i < m; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i < m i m 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 pr.println(ans) pr.println pr ans // ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	} main {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	} sc = new Scanner(System.in) sc new Scanner(System.in) pr = new Printer(System.out) pr new Printer(System.out) solve() solve pr.close() pr.close pr sc.close() sc.close sc String[] args args static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	} Printer Printer(OutputStream out) {
			super(out);
		} Printer {
			super(out);
		} super(out) super out OutputStream out out PrintWriter public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] cnt = new int[m];
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < m; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
} public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] cnt = new int[m];
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < m; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
} Main
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] cnt = new int[m];
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt() - 1;
				cnt[a]++;
			}
		}

		int ans = 0;
		for (int i = 0; i < m; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
