import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] Ms = new int[31];
		for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		}
		int cnt = 0;
		for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

} 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();
		int M = sc.nextInt();

		int[] Ms = new int[31];
		for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		}
		int cnt = 0;
		for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

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

		int[] Ms = new int[31];
		for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		}
		int cnt = 0;
		for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] Ms = new int[31];
		for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		}
		int cnt = 0;
		for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	} 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[] Ms = new int[31]; Ms new int[31] 31 for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		} 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 Aij = sc.nextInt();
				Ms[Aij]++;
			}
		} {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			} int j=0; int j=0; j 0 j<K j K j++ j++ j {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			} {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			} int Aij = sc.nextInt(); Aij sc.nextInt() sc.nextInt sc Ms[Aij]++ Ms[Aij] Ms Aij int cnt = 0; cnt 0 for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		} int i=0; int i=0; i 0 i<Ms.length i Ms.length Ms Ms.length i++ i++ i {
			if ( Ms[i] == N ) {
				cnt++;
			}
		} {
			if ( Ms[i] == N ) {
				cnt++;
			}
		} if ( Ms[i] == N ) {
				cnt++;
			} Ms[i] == N Ms[i] Ms i N {
				cnt++;
			} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt 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[] Ms = new int[31];
		for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		}
		int cnt = 0;
		for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] Ms = new int[31];
		for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		}
		int cnt = 0;
		for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] Ms = new int[31];
		for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		}
		int cnt = 0;
		for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}
