//2019/3/14
import java.util.Arrays;
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[] m = new int[M+1];

		Arrays.fill(m, 0);

		int K = 0;

		int A = 0;

		int ans = 0;

		for(int i=0;i<N;i++) {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		}

		for(int i=0;i<=M;i++) {

			if(m[i]==N) ans++;
		}

		System.out.println(ans);
	}

} import java.util.Arrays; Arrays java.util 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[] m = new int[M+1];

		Arrays.fill(m, 0);

		int K = 0;

		int A = 0;

		int ans = 0;

		for(int i=0;i<N;i++) {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		}

		for(int i=0;i<=M;i++) {

			if(m[i]==N) ans++;
		}

		System.out.println(ans);
	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int M = sc.nextInt();

		int[] m = new int[M+1];

		Arrays.fill(m, 0);

		int K = 0;

		int A = 0;

		int ans = 0;

		for(int i=0;i<N;i++) {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		}

		for(int i=0;i<=M;i++) {

			if(m[i]==N) ans++;
		}

		System.out.println(ans);
	} main {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int M = sc.nextInt();

		int[] m = new int[M+1];

		Arrays.fill(m, 0);

		int K = 0;

		int A = 0;

		int ans = 0;

		for(int i=0;i<N;i++) {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		}

		for(int i=0;i<=M;i++) {

			if(m[i]==N) ans++;
		}

		System.out.println(ans);
	} 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[] m = new int[M+1]; m new int[M+1] M+1 M 1 Arrays.fill(m, 0) Arrays.fill Arrays m 0 int K = 0; K 0 int A = 0; A 0 int ans = 0; ans 0 for(int i=0;i<N;i++) {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		} {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		} K = sc.nextInt() K sc.nextInt() sc.nextInt sc for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			} int j=0; int j=0; j 0 j<K j K j++ j++ j {

				A = sc.nextInt();

				m[A]++;
			} {

				A = sc.nextInt();

				m[A]++;
			} A = sc.nextInt() A sc.nextInt() sc.nextInt sc m[A]++ m[A] m A for(int i=0;i<=M;i++) {

			if(m[i]==N) ans++;
		} int i=0; int i=0; i 0 i<=M i M i++ i++ i {

			if(m[i]==N) ans++;
		} {

			if(m[i]==N) ans++;
		} if(m[i]==N) ans++; m[i]==N m[i] m i N ans++ ans System.out.println(ans) System.out.println System.out System System.out ans 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[] m = new int[M+1];

		Arrays.fill(m, 0);

		int K = 0;

		int A = 0;

		int ans = 0;

		for(int i=0;i<N;i++) {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		}

		for(int i=0;i<=M;i++) {

			if(m[i]==N) ans++;
		}

		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int M = sc.nextInt();

		int[] m = new int[M+1];

		Arrays.fill(m, 0);

		int K = 0;

		int A = 0;

		int ans = 0;

		for(int i=0;i<N;i++) {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		}

		for(int i=0;i<=M;i++) {

			if(m[i]==N) ans++;
		}

		System.out.println(ans);
	}

} Main
//2019/3/14
import java.util.Arrays;
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[] m = new int[M+1];

		Arrays.fill(m, 0);

		int K = 0;

		int A = 0;

		int ans = 0;

		for(int i=0;i<N;i++) {

			K = sc.nextInt();

			for(int j=0;j<K;j++) {

				A = sc.nextInt();

				m[A]++;
			}
		}

		for(int i=0;i<=M;i++) {

			if(m[i]==N) ans++;
		}

		System.out.println(ans);
	}

}
