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

		int[] l = new int[m];
		for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		}
		int r = 0;
		for (int i = 0; i < m; ++i) {
			if(l[i] == n) {
				r++;
			}
		}
		System.out.println(r);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
		int m = sc.nextInt();

		int[] l = new int[m];
		for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		}
		int r = 0;
		for (int i = 0; i < m; ++i) {
			if(l[i] == n) {
				r++;
			}
		}
		System.out.println(r);
	} main {
		Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
		int m = sc.nextInt();

		int[] l = new int[m];
		for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		}
		int r = 0;
		for (int i = 0; i < m; ++i) {
			if(l[i] == n) {
				r++;
			}
		}
		System.out.println(r);
	} 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[] l = new int[m]; l new int[m] m for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		} int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		} {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		} int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			} int j = 0; int j = 0; j 0 j < c j c ++j ++j j {
				int x = sc.nextInt();
				l[x - 1] += 1;
			} {
				int x = sc.nextInt();
				l[x - 1] += 1;
			} int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc l[x - 1] += 1 l[x - 1] l x - 1 x 1 1 int r = 0; r 0 for (int i = 0; i < m; ++i) {
			if(l[i] == n) {
				r++;
			}
		} int i = 0; int i = 0; i 0 i < m i m ++i ++i i {
			if(l[i] == n) {
				r++;
			}
		} {
			if(l[i] == n) {
				r++;
			}
		} if(l[i] == n) {
				r++;
			} l[i] == n l[i] l i n {
				r++;
			} r++ r System.out.println(r) System.out.println System.out System System.out r 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[] l = new int[m];
		for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		}
		int r = 0;
		for (int i = 0; i < m; ++i) {
			if(l[i] == n) {
				r++;
			}
		}
		System.out.println(r);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
		int m = sc.nextInt();

		int[] l = new int[m];
		for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		}
		int r = 0;
		for (int i = 0; i < m; ++i) {
			if(l[i] == n) {
				r++;
			}
		}
		System.out.println(r);
	}
} Main
import 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[] l = new int[m];
		for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		}
		int r = 0;
		for (int i = 0; i < m; ++i) {
			if(l[i] == n) {
				r++;
			}
		}
		System.out.println(r);
	}
}