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[] cnt = new int[m+1];
		int i, j;
		for(i=0; i <= m; i++) cnt[i] = 0;
		for(i = 0; i < n; i++) {
			int k0 = sc.nextInt();
			for(j = 0; j < k0; j++) {
				cnt[sc.nextInt()]++;
			}
		}
		sc = null;
		int cnt2 = 0;
		for(i=1; i <= m; i++) {
			if(cnt[i] == n)	cnt2++;
		}
		System.out.println(cnt2);
	}

} 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[] cnt = new int[m+1];
		int i, j;
		for(i=0; i <= m; i++) cnt[i] = 0;
		for(i = 0; i < n; i++) {
			int k0 = sc.nextInt();
			for(j = 0; j < k0; j++) {
				cnt[sc.nextInt()]++;
			}
		}
		sc = null;
		int cnt2 = 0;
		for(i=1; i <= m; i++) {
			if(cnt[i] == n)	cnt2++;
		}
		System.out.println(cnt2);
	}

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

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] cnt = new int[m+1];
		int i, j;
		for(i=0; i <= m; i++) cnt[i] = 0;
		for(i = 0; i < n; i++) {
			int k0 = sc.nextInt();
			for(j = 0; j < k0; j++) {
				cnt[sc.nextInt()]++;
			}
		}
		sc = null;
		int cnt2 = 0;
		for(i=1; i <= m; i++) {
			if(cnt[i] == n)	cnt2++;
		}
		System.out.println(cnt2);
	}

} 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[] cnt = new int[m+1];
		int i, j;
		for(i=0; i <= m; i++) cnt[i] = 0;
		for(i = 0; i < n; i++) {
			int k0 = sc.nextInt();
			for(j = 0; j < k0; j++) {
				cnt[sc.nextInt()]++;
			}
		}
		sc = null;
		int cnt2 = 0;
		for(i=1; i <= m; i++) {
			if(cnt[i] == n)	cnt2++;
		}
		System.out.println(cnt2);
	}

}
