import java.util.Scanner;

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

		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		}

		for(int a : like) {
			if(a==n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[] like = new int[m];
		int ans=0;

		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		}

		for(int a : like) {
			if(a==n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[] like = new int[m];
		int ans=0;

		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		}

		for(int a : like) {
			if(a==n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	} main {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[] like = new int[m];
		int ans=0;

		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		}

		for(int a : like) {
			if(a==n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt() n sc.nextInt() sc.nextInt sc m=sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] like = new int[m]; like new int[m] m int ans=0; ans 0 for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		} 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 num = sc.nextInt();
				like[num-1]+=1;
			}
		} {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		} int k=sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			} int j=0; int j=0; j 0 j<k j k j++ j++ j {
				int num = sc.nextInt();
				like[num-1]+=1;
			} {
				int num = sc.nextInt();
				like[num-1]+=1;
			} int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc like[num-1]+=1 like[num-1] like num-1 num 1 1 for(int a : like) {
			if(a==n) {
				ans++;
			}
		} int a like {
			if(a==n) {
				ans++;
			}
		} {
			if(a==n) {
				ans++;
			}
		} if(a==n) {
				ans++;
			} a==n a n {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[] like = new int[m];
		int ans=0;

		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		}

		for(int a : like) {
			if(a==n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[] like = new int[m];
		int ans=0;

		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		}

		for(int a : like) {
			if(a==n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
} Main
import java.util.Scanner;

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

		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		}

		for(int a : like) {
			if(a==n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}